`sentry release set-commits` ends with `Unexpected error: TypeError` when the release PUT is answered `200 {}`

オープン 初心者向け
#2,583 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
git, node.js, typescript
領域
api, cli

調査の方向性

未検証の応答は packages/cli/src/lib/api/releases.ts の updateRelease(374〜377行目付近)から来ており、クラッシュは packages/cli/src/commands/release/set-commits.ts の formatCommitsSet(407〜409行目付近)で発生しています。他の呼び出しが応答の形を確認するために使っている packages/cli/src/lib/api/infrastructure.ts の unwrapValidatedResult と比較してください。リンクされた gist の再現手順をローカルビルドに対して実行し、200 {} のケースを確認してください。200 {} がコミット設定の成功を報告するか、リリースの更新を名指しする ApiError で失敗すれば完了です。404 と 200-with-release のケースは変更しないでください。

索引モデルが issue の本文から書いたものです。

説明

Environment
  • sentry bundled from main at d9a498101c5e8ed7bd8db0fa71c43c76076e02a2 with no uncommitted changes (sentry --version: 0.52.0-dev.0), and [email protected] from npm, which does the same
  • node v26.12.1 on win32 x64, git version 2.56.0.windows.4
Steps to Reproduce
  1. In a git repository with an origin remote and two commits, run sentry release set-commits example-org/1.0.0 --local with SENTRY_URL pointing at a server that answers GET /api/0/organizations/example-org/ with the organization and PUT /api/0/organizations/example-org/releases/1.0.0/ with 200 {}, and SENTRY_AUTH_TOKEN set to any value.
  2. Run it again with the PUT answered 200 with the release, and with 404 {"detail":"not found"}.
Expected Result

With 200 {}, the command either reports the commits it set, or fails with an error that names the release update and its answer, as it does for the 404 (Error: Failed to update release '1.0.0': 404 Not Found). The PUT and the commits it carries stay as they are.

Actual Result

The PUT goes with both commits, then the command exits 1 with:

Unexpected error: TypeError: Cannot read properties of undefined (reading 'replace')

updateRelease returns the answer unchecked (packages/cli/src/lib/api/releases.ts#L374-L377), and formatCommitsSet passes its version to text() (packages/cli/src/commands/release/set-commits.ts#L407-L409). Other API calls check the answer's shape with unwrapValidatedResult (packages/cli/src/lib/api/infrastructure.ts#L1107-L1115), which throws ApiError naming the endpoint.

Reproducer

https://gist.github.com/YevheniiKotyrlo/8497fa9cdff5e0b58d4eccd8cd4f54ec

It makes a two-commit repository in a temporary folder, with no global or system git config, and runs the command three times against a local stand-in for the Sentry API that records each request, the release PUT answered with the release, with 404, and with 200 {}. It exits 1 while the 200 {} run ends in Unexpected error: TypeError after its PUT, 0 once that run exits 0 or fails naming the release update with no Unexpected error, 2 when a step fails, a control run or the 200 {} run ends another way, or the run is interrupted. Every child gets the caller's environment without its SENTRY_* and GIT_* variables, with TMPDIR, TEMP and TMP in the run's temporary folder. The run sets the repository's commit dates, its git user, an empty git config, commit.gpgsign=false and core.autocrlf=false, and gives the CLI SENTRY_HOST and SENTRY_URL (the stand-in), a placeholder SENTRY_AUTH_TOKEN, a SENTRY_CONFIG_DIR per run, SENTRY_CLI_NO_TELEMETRY and SENTRY_CLI_NO_UPDATE_CHECK. The verdict depends on SENTRY_HOST, SENTRY_URL and SENTRY_AUTH_TOKEN, which bring the requests to the stand-in; on SENTRY_CONFIG_DIR, since a stored sentry auth login takes priority over SENTRY_AUTH_TOKEN; and on leaving the caller's SENTRY_* and GIT_* variables out: with SENTRY_OUTPUT_FORMAT=json the command prints {} and exits 0, and a GIT_DIR points every git call at another repository. It depends as well on leaving the caller's git config out, since a hook it names can refuse the commits, and on the git user, without which git then makes no commit. It depends on none of the others. Paths below the temporary folder show as <tmp>. It needs git and no Sentry account.

node repro.mjs              # sentry@latest from npm
node repro.mjs <toolkit>    # a getsentry/toolkit checkout after `pnpm install`: runs `pnpm run bundle` in packages/cli first

Its output on main:

node v26.12.1 on win32 x64
git version 2.56.0.windows.4

$ # sentry: getsentry/toolkit at d9a498101c5e8ed7bd8db0fa71c43c76076e02a2, no uncommitted changes
$ pnpm run bundle   # in packages/cli

$ git log --oneline
95c4fde Change the answer
9fda718 Add the app

$ sentry --version
0.52.0-dev.0

# the release PUT answered 200 with the release
$ sentry release set-commits example-org/1.0.0 --local
Commits Set: 1.0.0
━━━━━━━━━━━━━━━━━━

╭─────────┬───────╮
│ Version │ 1.0.0 │
│ Commits │ 2     │
╰─────────┴───────╯
exit 0; requests: GET /api/0/organizations/example-org/ -> 200, PUT /api/0/organizations/example-org/releases/1.0.0/ -> 200
the PUT carried 2 commits: 95c4fde, 9fda718

# the release PUT answered 404 {"detail":"not found"}
$ sentry release set-commits example-org/1.0.0 --local
Error: Failed to update release '1.0.0': 404 Not Found
  not found
exit 30; requests: GET /api/0/organizations/example-org/ -> 200, PUT /api/0/organizations/example-org/releases/1.0.0/ -> 404
the PUT carried 2 commits: 95c4fde, 9fda718

# the release PUT answered 200 {}
$ sentry release set-commits example-org/1.0.0 --local
Unexpected error: TypeError: Cannot read properties of undefined (reading 'replace')
(10 stack frames not shown)
exit 1; requests: GET /api/0/organizations/example-org/ -> 200, PUT /api/0/organizations/example-org/releases/1.0.0/ -> 200
the PUT carried 2 commits: 95c4fde, 9fda718

RESULT (exit 1): defect shows (sentry 0.52.0-dev.0 built from d9a498101c5e): with the PUT answered 200 {}, the command exited 1 with "Unexpected error: TypeError..." after the PUT had gone
主要言語
TypeScript
スター
975
フォーク
189
平均マージ
19時間 57分
マージ済み PR(30日)
542

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

getsentry/toolkit のほかの issue

getsentry/toolkit の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。