`.sentryclirc` with a self-hosted `url` refuses commands and SDK calls whose `SENTRY_URL`, `SENTRY_HOST` or `url` option names another server
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ó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 22/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ệ
- nodejs, typescript
- Lĩnh vực
- api, authentication, cli
Hướng nghiên cứu
Start with assertRcUrlTrusted in packages/cli/src/lib/sentryclirc.ts (around L422-457) and its call sites in packages/cli/src/lib/command.ts (L588-589, L895-898), then compare with the override handling in applySentryCliRcEnvShim (L398-408) and the existing mcp.ts host check (L419-429). Run the linked repro.mjs with a self-hosted .sentryclirc url and SENTRY_URL set. Done means the reproducer exits 0 for the runs that name the stand-in, while the token-trust and no-override refusals still hold.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Environment
sentrybuilt frommainat 5f11870fefae0818025715619f41a597607c4ef9 (sentry --version:0.52.0-dev.0), and[email protected]from npm, which does the same- node v26.12.1 on win32 x64, and node v20.20.2, which does the same
Steps to Reproduce
- Write
~/.sentryclirc:[defaults] url=https://sentry.example.com - Run
sentry release view example-org/1.0.0withSENTRY_AUTH_TOKENset andSENTRY_URLnaming another server (here a local stand-in for the Sentry API). - Run it again with
SENTRY_HOSTnaming that server instead ofSENTRY_URL. - Call
createSentrySDK({ url, token }).release.view({ orgVersion: "example-org/1.0.0" })withurlnaming that server. - Repeat steps 2 to 4 with no
~/.sentryclirc, and with one whoseurlishttps://sentry.io/.
Expected Result
Steps 2 to 4 send their requests to the server they name and show the release, as every run of step 5 does. With SENTRY_URL or SENTRY_HOST set (the SDK's url sets SENTRY_HOST), the .sentryclirc URL is not applied (applySentryCliRcEnvShim). I ask this only where an explicit override names where the requests go: SENTRY_URL, SENTRY_HOST or the SDK's url.
The check stays:
- for a self-hosted
.sentryclircURL the CLI applies, with neither variable set; - for a
.sentryclircwhose[auth] tokenbecomes the token in use (L385-L396), so the file's token does not go to the server the environment names.
I leave the refusal of createSentrySDK({ token }) without url as it is: its requests would go to sentry.io (sdk-types.ts#L21-L26) while the file names another server, so that refusal flags a real conflict.
Actual Result
Steps 2, 3 and 4 each fail with exit code 13 (Host Scope) before sending any request. Step 2:
$ SENTRY_URL=http://127.0.0.1:62387 SENTRY_AUTH_TOKEN=example-token sentry release view example-org/1.0.0
Error: Config at <tmp>\home-self-hosted\.sentryclirc: https://sentry.example.com
Refusing to route requests here because it doesn't match the host your Sentry credentials are for (http://127.0.0.1:62387).
To use this host, run: sentry auth login --url https://sentry.example.com
To keep using your current credentials, remove this URL override.
exit 13; requests the stand-in received: none
Step 4:
> createSentrySDK({ url: "http://127.0.0.1:62387", token: "example-token" }).release.view({ orgVersion: "example-org/1.0.0" })
Config at <tmp>\home-self-hosted\.sentryclirc: https://sentry.example.com
Refusing to route requests here because it doesn't match the host your Sentry credentials are for (http://127.0.0.1:62387).
To use this host, run: sentry auth login --url https://sentry.example.com
To keep using your current credentials, remove this URL override.
exitCode 13
exit 13; requests the stand-in received: none
Every run of step 5 reaches the server and shows the release.
assertRcUrlTrusted checks the .sentryclirc URL whether or not the environment overrides it, and the command wrapper calls it before every command that does not opt out (L588-L589, L895-L898).
docs/operations/stdio-auth.md describes this refusal for sentry mcp as "the same check every CLI command applies", made "instead of sending any token to that host". With SENTRY_URL or SENTRY_HOST set, no request goes to that host: with a .sentryclirc naming sentry.io, step 5's requests go to the server the environment names. sentry mcp --host, which the same page says runs "as if SENTRY_URL were set", already skips the check (mcp.ts#L419-L429, from #1801), while its deprecation warning says to "use SENTRY_HOST instead" (mcp.ts#L403-L407, mcp/args.ts#L99-L109), which this check refuses. No test that expects the refusal sets SENTRY_URL or SENTRY_HOST.
#2538 (for #2537) trusts a .sentryclirc URL that matches the url claim of an sntrys_ token read from a .sentryclirc. It leaves this case as it was: the token here comes from the environment, and the SDK's token becomes SENTRY_AUTH_TOKEN as well (sdk-invoke.ts#L46-L49). #2580 meets the same refusal from the SDK, under a .sentryclirc above the repository root that sentry commands do not read.
Reproducer
https://gist.github.com/YevheniiKotyrlo/04b4403a8fcd7cec71b53ccd051615cc
It runs steps 2 to 5 in a temporary folder against a local stand-in for the Sentry API that records each request. Each run starts from the caller's environment without its SENTRY_* and GIT_* variables and sets its own: TMPDIR, TEMP and TMP (a folder inside the temporary folder), HOME and USERPROFILE (one of three home folders), SENTRY_CONFIG_DIR (a folder of its own), the step's SENTRY_URL or SENTRY_HOST with SENTRY_AUTH_TOKEN (or the SDK's url and token), and SENTRY_CLI_NO_TELEMETRY, SENTRY_CLI_NO_UPDATE_CHECK and NO_COLOR. The verdict depends on the home folder, the server named and the token. SENTRY_CONFIG_DIR keeps out a stored login, which would let the check pass, and the response cache; the last three keep telemetry, the update check and colour out of the runs. It exits 1 while a run that names the stand-in is refused (exit 13, or the refusal's words, with no request sent), 0 once those runs reach the stand-in, 2 when a step fails or the run ends another way. A .sentryclirc that sets url in a folder above the temporary folder would apply to every run, so the reproducer then stops with 2; point TMPDIR (TEMP and TMP on Windows) at a folder with none above it. It needs Node 20+, and no Sentry account.
node repro.mjs # sentry@latest from npm
node repro.mjs 0.50.0 # a given version from npm
node repro.mjs <toolkit> # a getsentry/toolkit checkout: runs `pnpm run bundle` in packages/cli first
Its result on main:
RESULT (exit 1): defect shows (sentry 0.52.0-dev.0 built from 5f11870fefae): the self-hosted .sentryclirc URL refused 3 of 3 runs that name another server (SENTRY_URL, SENTRY_HOST, createSentrySDK url), with no request sent; the runs without it reached the stand-in
Its whole output on main
node v26.12.1 on win32 x64
$ # sentry: getsentry/toolkit at 5f11870fefae0818025715619f41a597607c4ef9, no uncommitted changes
$ pnpm run bundle # in packages/cli
$ sentry --version
0.52.0-dev.0
# HOME: no .sentryclirc
$ SENTRY_URL=http://127.0.0.1:62387 SENTRY_AUTH_TOKEN=example-token sentry release view example-org/1.0.0
Release 1.0.0
━━━━━━━━━━━━━
╭─────────────┬─────────────╮
│ Version │ 1.0.0 │
│ Status │ Unreleased │
│ Created │ Jan 1 │
│ Released │ — │
│ First Event │ — │
│ Last Event │ — │
│ Ref │ — │
│ Commits │ 0 │
│ Deploys │ 0 │
│ New Issues │ 0 │
│ Projects │ example-app │
╰─────────────┴─────────────╯
exit 0; requests the stand-in received: GET /api/0/organizations/example-org/ -> 200, GET /api/0/organizations/example-org/releases/1.0.0/ -> 200
# HOME: .sentryclirc naming sentry.io (url=https://sentry.io/)
$ SENTRY_URL=http://127.0.0.1:62387 SENTRY_AUTH_TOKEN=example-token sentry release view example-org/1.0.0
Release 1.0.0
━━━━━━━━━━━━━
╭─────────────┬─────────────╮
│ Version │ 1.0.0 │
│ Status │ Unreleased │
│ Created │ Jan 1 │
│ Released │ — │
│ First Event │ — │
│ Last Event │ — │
│ Ref │ — │
│ Commits │ 0 │
│ Deploys │ 0 │
│ New Issues │ 0 │
│ Projects │ example-app │
╰─────────────┴─────────────╯
exit 0; requests the stand-in received: GET /api/0/organizations/example-org/ -> 200, GET /api/0/organizations/example-org/releases/1.0.0/ -> 200
# HOME: .sentryclirc naming a self-hosted server (url=https://sentry.example.com)
$ SENTRY_URL=http://127.0.0.1:62387 SENTRY_AUTH_TOKEN=example-token sentry release view example-org/1.0.0
Error: Config at <tmp>\home-self-hosted\.sentryclirc: https://sentry.example.com
Refusing to route requests here because it doesn't match the host your Sentry credentials are for (http://127.0.0.1:62387).
To use this host, run: sentry auth login --url https://sentry.example.com
To keep using your current credentials, remove this URL override.
exit 13; requests the stand-in received: none
# HOME: no .sentryclirc
$ SENTRY_HOST=http://127.0.0.1:62387 SENTRY_AUTH_TOKEN=example-token sentry release view example-org/1.0.0
Release 1.0.0
━━━━━━━━━━━━━
╭─────────────┬─────────────╮
│ Version │ 1.0.0 │
│ Status │ Unreleased │
│ Created │ Jan 1 │
│ Released │ — │
│ First Event │ — │
│ Last Event │ — │
│ Ref │ — │
│ Commits │ 0 │
│ Deploys │ 0 │
│ New Issues │ 0 │
│ Projects │ example-app │
╰─────────────┴─────────────╯
exit 0; requests the stand-in received: GET /api/0/organizations/example-org/ -> 200, GET /api/0/organizations/example-org/releases/1.0.0/ -> 200
# HOME: .sentryclirc naming sentry.io (url=https://sentry.io/)
$ SENTRY_HOST=http://127.0.0.1:62387 SENTRY_AUTH_TOKEN=example-token sentry release view example-org/1.0.0
Release 1.0.0
━━━━━━━━━━━━━
╭─────────────┬─────────────╮
│ Version │ 1.0.0 │
│ Status │ Unreleased │
│ Created │ Jan 1 │
│ Released │ — │
│ First Event │ — │
│ Last Event │ — │
│ Ref │ — │
│ Commits │ 0 │
│ Deploys │ 0 │
│ New Issues │ 0 │
│ Projects │ example-app │
╰─────────────┴─────────────╯
exit 0; requests the stand-in received: GET /api/0/organizations/example-org/ -> 200, GET /api/0/organizations/example-org/releases/1.0.0/ -> 200
# HOME: .sentryclirc naming a self-hosted server (url=https://sentry.example.com)
$ SENTRY_HOST=http://127.0.0.1:62387 SENTRY_AUTH_TOKEN=example-token sentry release view example-org/1.0.0
Error: Config at <tmp>\home-self-hosted\.sentryclirc: https://sentry.example.com
Refusing to route requests here because it doesn't match the host your Sentry credentials are for (http://127.0.0.1:62387).
To use this host, run: sentry auth login --url https://sentry.example.com
To keep using your current credentials, remove this URL override.
exit 13; requests the stand-in received: none
# HOME: no .sentryclirc
> createSentrySDK({ url: "http://127.0.0.1:62387", token: "example-token" }).release.view({ orgVersion: "example-org/1.0.0" })
returned release 1.0.0
exit 0; requests the stand-in received: GET /api/0/organizations/example-org/ -> 200, GET /api/0/organizations/example-org/releases/1.0.0/ -> 200
# HOME: .sentryclirc naming sentry.io (url=https://sentry.io/)
> createSentrySDK({ url: "http://127.0.0.1:62387", token: "example-token" }).release.view({ orgVersion: "example-org/1.0.0" })
returned release 1.0.0
exit 0; requests the stand-in received: GET /api/0/organizations/example-org/ -> 200, GET /api/0/organizations/example-org/releases/1.0.0/ -> 200
# HOME: .sentryclirc naming a self-hosted server (url=https://sentry.example.com)
> createSentrySDK({ url: "http://127.0.0.1:62387", token: "example-token" }).release.view({ orgVersion: "example-org/1.0.0" })
Config at <tmp>\home-self-hosted\.sentryclirc: https://sentry.example.com
Refusing to route requests here because it doesn't match the host your Sentry credentials are for (http://127.0.0.1:62387).
To use this host, run: sentry auth login --url https://sentry.example.com
To keep using your current credentials, remove this URL override.
exitCode 13
exit 13; requests the stand-in received: none
RESULT (exit 1): defect shows (sentry 0.52.0-dev.0 built from 5f11870fefae): the self-hosted .sentryclirc URL refused 3 of 3 runs that name another server (SENTRY_URL, SENTRY_HOST, createSentrySDK url), with no request sent; the runs without it reached the stand-in
- 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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của getsentry/toolkit
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
getsentry/toolkit#2583 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
getsentry/toolkit#2531 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
mcp-feedback-pattern
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
getsentry/toolkit#2458 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
getsentry/toolkit#2444 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
mcp-feedback-pattern
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
getsentry/toolkit#2362 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của getsentry/toolkit
Issue tương tự
-
sumHorizontal, maxHorizontal, minHorizontal, allHorizontal, anyHorizontal, struct and argSortBy treat strings as literals instead of column namesCó thể đã có người làm @tomaionescu đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
pola-rs/nodejs-polars#486 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
jaegertracing/jaeger-ui#4853 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/plugins platform/linux reproduced type/bug version/v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
anomalyco/opencode#66970 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:tui enhancement platform:macos
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
anthropics/claude-code#112838 ·
-
Add: Sports First TV (US)Đang mởapproved check:passed streams:add
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày