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

Đang mở Phù hợp với người mới
#2,583 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
git, node.js, typescript
Lĩnh vực
api, cli

Hướng nghiên cứu

Phản hồi chưa được kiểm tra đến từ updateRelease trong packages/cli/src/lib/api/releases.ts (khoảng dòng 374-377), còn lỗi crash nằm ở formatCommitsSet trong packages/cli/src/commands/release/set-commits.ts (khoảng dòng 407-409). Hãy so sánh với unwrapValidatedResult trong packages/cli/src/lib/api/infrastructure.ts, hàm mà các lời gọi khác dùng để kiểm tra cấu trúc phản hồi. Chạy repro trong gist được liên kết với bản build cục bộ để xác nhận trường hợp 200 {}. Hoàn thành khi 200 {} báo rằng các commit đã được thiết lập, hoặc thất bại với một ApiError nêu rõ việc cập nhật release, và các trường hợp 404 và 200-có-release giữ nguyên.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
TypeScript
Star
975
Fork
189
Merge trung bình
19 giờ 57 phút
Pull request đã merge (30 ngày)
542

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của getsentry/toolkit

Tất cả issue của getsentry/toolkit

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.