Skip to content

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

Open

Description

@luojiyin1987

问题

当 url 输入为空时(典型场景:调用方传入的 secret 在当前触发环境下不可用),action 抛出 undici 的底层错误:

##[error]No URL protocol specified
Process completed with exit code 1.

用户无法从这条日志判断原因。

实际案例:Open-Source-Bazaar.github.io 的 Lark notification workflow 在 fork PR 上失败。GitHub 对 fork PR 不暴露仓库 secrets,url: ${{ secrets.LARK_CHATBOT_HOOK_URL }} 展开为空字符串,最终报出上述错误:

Open-Source-Bazaar/Open-Source-Bazaar.github.io#113

根因

src/main.ts 的 post() 把 core.getInput('url') 直接传给 got.post(),没有对空值做前置校验。

改进方案

在发起请求前检测空 URL,输出可操作的错误信息并保持失败退出(不改变"配置错误即失败"的语义):

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.

这样遇到此问题的人从日志即可定位原因。

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions