Skip to content

fix: report actionable error when url input is empty - #16

Open
luojiyin1987 wants to merge 1 commit into
masterfrom
fix/empty-url-error-message
Open

luojiyin1987 wants to merge 1 commit into
masterfrom
fix/empty-url-error-message

Conversation

@luojiyin1987

@luojiyin1987 luojiyin1987 commented Aug 25, 2026 •

Copy link
Copy Markdown

Fixes #15

改动

src/main.ts 的 post() 在发起请求前校验 url 输入。为空时输出可操作的错误并失败退出:

::error::The "url" input is empty. Check that the secret is configured and passed correctly.
Note: repository secrets are unavailable to workflows triggered by fork pull requests.

替代原来 undici 抛出的底层错误 No URL protocol specified。

设计说明

保持"配置错误即失败"的语义不变,不静默跳过:

  • action 无法区分"fork PR 无 secret(预期)"、"secret 名拼错"、"secret 未配置"。静默跳过会掩盖后两种配置错误
  • 现有 @V3 消费者依赖非法 URL 即失败的契约,静默跳过属于 breaking change
  • 调用方如需在 secret 缺失时跳过,应在 workflow 的 if 条件里处理(参考 Open-Source-Bazaar.github.io#114)

验证

  • tsc、ncc pack、jest(1/1)、eslint、prettier 通过
  • 实测空 INPUT_URL:输出上述错误日志,exit 1
  • 正常 URL 路径不变(守卫仅空值触发)
  • dist/index.js 已随源码重新打包

Summary by CodeRabbit

  • Bug Fixes
    • Added validation to prevent message submissions when the URL is missing.
    • Displays a clearer error explaining that the required secret may be unavailable, including for workflows triggered by forked pull requests.

@coderabbitai

coderabbitai Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 393e91e4-93a7-481a-ba49-4dbfb49b2e4b

📥 Commits

Reviewing files that changed from the base of the PR and between a329354 and aed10b5.

⛔ Files ignored due to path filters (1)
  • dist/index.js is excluded by !**/dist/**
📒 Files selected for processing (1)
  • src/main.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The post function now checks for an empty URL before sending a request. It throws an error that identifies possible secret configuration issues and fork pull request restrictions.

Changes

URL validation

Layer / File(s) Summary
Pre-request URL validation
src/main.ts
The post function throws a descriptive error when url is empty. The check runs before got.post.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Merge Risk: ⚪ Minimal · up to aed10

The change provides a clearer failure message for empty URL configuration while preserving the existing fail-fast behavior; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: reporting an actionable error when the URL input is empty.
Linked Issues check ✅ Passed The change satisfies issue #15 by validating the URL before the request, reporting the required actionable guidance, and preserving failure behavior for configuration errors.
Out of Scope Changes check ✅ Passed The reviewed change is limited to empty URL validation and directly supports the linked issue objectives. No unrelated changes are shown.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/empty-url-error-message

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

空 url 输入时报错不明确(No URL protocol specified),缺少前置校验

1 participant