`.sentryclirc` with a self-hosted `url` refuses commands and SDK calls whose `SENTRY_URL`, `SENTRY_HOST` or `url` option names another server
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 22/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- nodejs, typescript
- 领域
- api, authentication, cli
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- TypeScript
- 星标
- 975
- 派生
- 189
- 平均合并
- 19 小时 57 分钟
- 30 天内合并 PR
- 542
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
getsentry/toolkit 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
getsentry/toolkit#2583 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
getsentry/toolkit#2531 · 1 条评论 ·
维护者通常 1 天内回复
-
mcp-feedback-pattern
难度 2/5 1-3 小时 新手友好度 74/100
getsentry/toolkit#2458 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
getsentry/toolkit#2444 · 1 条评论 ·
维护者通常 1 天内回复
-
mcp-feedback-pattern
难度 2/5 1-3 小时 新手友好度 67/100
getsentry/toolkit#2362 · 1 条评论 ·
维护者通常 1 天内回复
查看 getsentry/toolkit 的全部 Issue
相似的 Issue
-
Release utils decode git output chunk by chunk, so a multi-byte character can turn into U+FFFD可能已有人在做 @goranai 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 2 天内回复
-
Task retarget keeps the old host in task scope and adds the new host in a form that matches nothing可能已有人在做 @chaitanya0305 今天认领。 未关闭bug P2
难度 2/5 1-3 小时 新手友好度 62/100
BaaRai/ARTEX#652 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
compiler-explorer/compiler-explorer#9710 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
bug effort:S P3
难度 2/5 1-3 小时 新手友好度 72/100
nightscout/nocturne#4556 ·
维护者通常 1 天内回复