Skip to content

Commit 19b2357

Browse files
betegonclaude
andcommitted
fix(auth): use this.cwd and tighten rc token hint host matching
Two fixes: - resolveRcContext now uses this.cwd (injected via SentryContext) instead of process.cwd(), making rc-related login behavior testable - rcTokenHint now suppresses the hint when .sentryclirc has no URL and effectiveHost is self-hosted — a bare token in rc is almost certainly a SaaS token and pairing it with a self-hosted --url would always fail Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent bfed8bf commit 19b2357

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/commands/auth/login.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,12 @@ function rcTokenHint(
191191
const rcUrl = rcConfig.url
192192
? normalizeOrigin(normalizeUrl(rcConfig.url))
193193
: undefined;
194-
if (rcUrl && rcUrl !== normalizeOrigin(effectiveHost)) {
195-
return;
194+
if (rcUrl) {
195+
// rc has an explicit URL — only hint if it matches the current host
196+
if (rcUrl !== normalizeOrigin(effectiveHost)) return;
197+
} else {
198+
// No URL in rc — assume a bare SaaS token; don't hint on self-hosted
199+
if (!isSaaSTrustOrigin(effectiveHost)) return;
196200
}
197201
// Always include --url for self-hosted instances regardless of how the host
198202
// was supplied — omitting it would point the user at SaaS instead.
@@ -362,7 +366,7 @@ export const loginCommand = buildCommand({
362366
// the source file in trust-refusal errors and show a migration tip.
363367
const { rcConfig, urlFromRc } = await resolveRcContext(
364368
flags.url,
365-
process.cwd(),
369+
this.cwd,
366370
effectiveHost
367371
);
368372

0 commit comments

Comments
 (0)