fix(ci): 跨仓库客户端改名——github-script 本来就声明了 octokit(修 #4553 引入的红检查) - #4573
Merged
Conversation
…s `octokit` `actions/github-script` injects an `octokit` binding, so `const octokit = ...` aborts the run with a SyntaxError before any logic executes. Caught on #4553's own merge, the first time the workflow ever ran; until this lands every merged PR carries one red check. The pre-merge `node --check` missed it because the test wrapper declared only {github, context, core, require} — a wrapper that omits an injected identifier cannot see a collision with it. The wrapper now carries the full set.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Without this the job returns early whenever a PR body carries no cross-repo reference — which is most PRs — so a repository that has the secret and one that does not produce byte-identical logs. Whether the credential is provisioned stays unanswerable until a cross-repo reference happens to show up, possibly days later. Presence only; the value is never read into the log.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
紧急度说明:#4553 合入后,当前
main上每一个 PR 合并都会挂一个红检查。 本 PR 修掉它。失败
actions/github-script会往脚本作用域注入一个octokit绑定,而 #4553 里我写了const octokit = require('@actions/github').getOctokit(token)。于是一行业务逻辑都没执行就崩了:(run 30738782877,
run_number: 1—— 该工作流有史以来的第一次运行,发生在 #4553 自身的合并事件上。)改法:把那个客户端改名为
crossRepo。注释保留原意——github绑定的是GITHUB_TOKEN,对本仓库之外没有写权限,所以才需要第二个客户端。合并前的验证为什么没抓到它——这一点比修复本身值得记
#4553 合并前我做过
node --check,而且它报告通过。用的包装是:一个不声明某个注入标识符的包装,不可能看见与它的命名冲突。 检查回答的是一个比运行时更窄的问题,却被当成了同一个问题的答案——所以它给出的绿灯是真实的,只是无关。
本 PR 把包装补成
github-script实际注入的全集:并做了反证:旧写法(
const octokit = …)在新包装下确实报SyntaxError,新写法通过。也就是说这道检查现在对这类缺陷有判别力,而不只是能通过。与本仓库正在修的一类问题同形
#4553 的正文里我写过「本 PR 自身合并即是它的第一次真实执行,这本身就是可观察的验收信号」,后来又发更正评论说它多半不会在自己的合并上触发。那条更正也是错的——它确实触发了(base`` 分支在
closed事件发出时已含该文件)。一句原始声明加一句更正,两条都不准,而真实结果是第三种:触发了,然后崩了。这正是 #4550 记录的形状——静态检查通过被当成了运行时正确,而两者回答的不是同一个问题。这次的实例已经写进 #4550 的语境里。
验证状态(如实)
No cross-repository closing keywords in this PR body.并成功退出。这是可核验的预期,不是验收结论;若它再次失败,请以 Actions 日志为准。配套修复已推到 objectui 的 #3179(尚未合并,在合并前修掉,那边不会经历这一轮红)。
Generated by Claude Code