full-sync crashes on 2.1.19+ with "Cannot read properties of null (reading 'info')" — probot 14 leaves Probot#log null

未关闭
#1,073 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
58/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
领域
cli, devops

调研方向

从 full-sync.js、createProbot() 和三个 probot.log call sites 开始,然后在文档所述的 Actions-mode setup 中运行 npm run full-sync。比较针对 probot 14 描述的 logger 生命周期,并确定对所有调用的一致处理方式。当 full-sync 在 2.1.19+ 上启动并完成协调,且不丢失其运行状态日志时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

Problem Description

What is actually happening

npm run full-sync (Actions mode) crashes immediately on 2.1.19, 2.1.20 and
2.1.21. It fails before any GitHub API call, so a scheduled full sync never
starts and nothing is reconciled.

full-sync.js calls probot.log.info() as the first statement after
createProbot():

const probot = createProbot()
probot.log.info(`Starting full sync with NOP=${nop}`)   // line 7

Since 2.1.19 the probot dependency is ^14.2.4. In probot 14,
src/probot.ts
declares the logger nullable and initialises it to null:

log: Logger | null;                 // line 55
...
log: options.log || null,           // line 114

The real logger is only constructed later, during initialization
(lines ~153–163), and probot's own code guards the field accordingly:

if (this.#state.log) {              // line 203

createProbot() returns before any of that runs, so probot.log is null
and the dereference on full-sync.js:7 throws.

This is not configuration-dependent: no environment variable affects it.
LOG_LEVEL is irrelevant because the logger object does not exist yet.

What is the expected behavior

full-sync starts and reconciles, as it does on 2.1.18.

Error output, if available
> [email protected] full-sync
> node ./full-sync.js

Fatal error during full sync: TypeError: Cannot read properties of null (reading 'info')
    at performFullSync (/home/runner/work/.github/.github/.safe-settings/full-sync.js:7:14)
    at Object.<anonymous> (/home/runner/work/.github/.github/.safe-settings/full-sync.js:25:1)
    at Module._compile (node:internal/modules/cjs/loader:1781:14)
    at Object..js (node:internal/modules/cjs/loader:1913:10)
    at Module.load (node:internal/modules/cjs/loader:1505:32)
    at Function._load (node:internal/modules/cjs/loader:1309:12)
    at wrapModuleLoad (node:internal/modules/cjs/loader:254:19)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:171:5)
Affected versions
tag probot engines.node full-sync
2.1.18 ^13.4.4 >= 16.0.0 works
2.1.19 ^14.2.4 >= 22.0.0 crashes
2.1.20 ^14.2.4 >= 22.0.0 crashes
2.1.21 ^14.2.4 >= 22.0.0 crashes

full-sync.js is byte-identical between 2.1.18 and 2.1.21, so the change in
behaviour comes entirely from the probot major bump, not from an edit to that
file.

3.0.0-rc.1 still pins probot: ^13.4.4, so it is unaffected — but its
full-sync.js has the same unguarded probot.log.info() on the line after
createProbot(), so the same crash returns if that branch ever moves to
probot 14. 2.2.0-rc.2 has the same shape at the top level of the module.

Reproduction

Any Actions-mode setup on 2.1.19+ reproduces it; the config is irrelevant
because it crashes before reading anything:

- uses: actions/checkout@v5
  with: { repository: github-community-projects/safe-settings, ref: 2.1.21, path: .safe-settings }
- run: npm ci
  working-directory: .safe-settings
- run: npm run full-sync
  working-directory: .safe-settings
  env:
    GH_ORG: <org>
    APP_ID: ${{ vars.SAFE_SETTINGS_APP_ID }}
    PRIVATE_KEY: ${{ secrets.SAFE_SETTINGS_PRIVATE_KEY }}
    ADMIN_REPO: .github
    CONFIG_PATH: safe-settings
Possible fixes

I have not sent a PR because the right choice depends on how you want probot
14 supported, but the options seem to be:

  1. Obtain a logger explicitly rather than relying on the instance field, e.g.
    pass one in via createProbot({ overrides: { log } }).
  2. Await whatever initialises the instance before the first log use.
  3. Guard the call sites in full-sync.js — this keeps it running but silently
    loses the "Starting full sync" and "Full sync completed successfully" lines,
    which are the only account of a run in Actions mode.
  4. Pin probot back to ^13 until 14 is supported deliberately.

Whichever is chosen, full-sync.js uses probot.log in three places — the
two info calls and the error call in the settings.errors branch — so all
of them need the same treatment.

Context

Are you using the hosted instance of probot/settings or running your own?

Running our own, in Actions mode (npm run full-sync from a workflow), not a
hosted Probot service.

If running your own instance, are you using it with github.com or GitHub Enterprise?

github.com.

Version of probot/settings

2.1.21 (also confirmed on 2.1.19 and 2.1.20 by inspection; 2.1.18 works).

Version of GitHub Enterprise

N/A.

主要语言
JavaScript
星标
942
派生
238
PR 合并指标
30 天内没有已合并 PR

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

github-community-projects/safe-settings 的其他 Issue

查看 github-community-projects/safe-settings 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。