Skip to content

Commit 79cac20

Browse files
crowlbotclaude
andcommitted
chore(auth): route browser-flow prompts + diagnostics to stderr
Move four log sites from stdout to stderr so that `--json` callers (and anyone piping the CLI's stdout) stop seeing human/diagnostic chatter mixed into machine-readable output: - The OAuth browser-flow prompt ("Visit ... to authorize ..."): this is a prompt directed at the human at the terminal; it belongs on stderr, not on stdout where it would corrupt a piped JSON payload. - "Authorization successful. Authenticated as ...": status message, not data; stderr. - The 401 response body that `authedFetch` logs when re-authenticating: always a diagnostic; gated on `--debug` and emitted to stderr. - The retry-link's `console.log(opts)` debug dump: stderr (was the only stdout debug write in auth.ts). The keychain-unavailable warning was already moved to stderr in #91. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 43d0b9a commit 79cac20

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

auth.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export function createTrpcClient(
113113
retryLink({
114114
retry(opts) {
115115
if (context.debug) {
116-
console.log(opts);
116+
console.error(opts);
117117
}
118118

119119
if (
@@ -243,7 +243,8 @@ export async function getAuth(
243243
message: "",
244244
color: "yellow",
245245
});
246-
console.log(`Visit ${authUrl} to authorize deploying your project.`);
246+
// Prompt-style message — goes to stderr so it doesn't pollute `--json` callers' stdout.
247+
console.error(`Visit ${authUrl} to authorize deploying your project.`);
247248
if (!quiet) {
248249
spinner.start();
249250
}
@@ -310,7 +311,8 @@ export function tokenExchange(
310311
const { token, user } = await res.json();
311312
spinner.stop();
312313
if (!quiet) {
313-
console.log(
314+
// Status message — stderr so JSON callers' stdout stays clean.
315+
console.error(
314316
`${
315317
green("✔")
316318
} Authorization successful. Authenticated as ${user.name}\n`,
@@ -368,7 +370,8 @@ export async function authedFetch(
368370
});
369371

370372
if (res.status === 401) {
371-
console.log(await res.text());
373+
// Diagnostic body — stderr only, and only when debugging.
374+
if (context.debug) console.error(await res.text());
372375
tokenStorage.remove();
373376
auth = await getAuth(context);
374377

0 commit comments

Comments
 (0)