fix(cli): Write --output file on auth error early exit#214
fix(cli): Write --output file on auth error early exit#214
Conversation
The auth error catch block returned without writing to the --output file, unlike other early-exit paths that call writeEmptyRunLog(). This left downstream consumers without the expected output file. Warden finding find-warden-bugs-9fff8c6a Severity: high Co-Authored-By: Warden <noreply@getsentry.com>
cfb86fa to
bfdcef1
Compare
| } catch (error: unknown) { | ||
| reporter.error((error as WardenAuthenticationError).message); | ||
| writeEmptyRunLog(repoPath ?? cwd, { traceId: getTraceId(), outputPath: options.output }); | ||
| return 1; |
There was a problem hiding this comment.
Auth error early exit skips JSON stdout output unlike other early exit paths
The auth error catch block calls writeEmptyRunLog() but does not check options.json and write content to stdout. All other early exit paths (no skills matched, no files matched, etc.) have a pattern: if (options.json) { const { content } = writeEmptyRunLog(...); process.stdout.write(content); }. This inconsistency means when --json is used with a failing auth, the output file is written but stdout remains empty, which can break downstream consumers expecting JSON output on stdout.
Verification
Read lines 379-389, 457-466, 646-658 confirming all other early exit paths check options.json and write to stdout. The auth catch block at lines 325-328 writes the file but skips the stdout output.
Suggested fix: Match the pattern used by other early exit paths: check options.json and write content to stdout if true.
| } catch (error: unknown) { | |
| reporter.error((error as WardenAuthenticationError).message); | |
| writeEmptyRunLog(repoPath ?? cwd, { traceId: getTraceId(), outputPath: options.output }); | |
| return 1; | |
| if (options.json) { | |
| const { content } = writeEmptyRunLog(repoPath ?? cwd, { traceId: getTraceId(), outputPath: options.output }); | |
| process.stdout.write(content); | |
| } else { | |
| writeEmptyRunLog(repoPath ?? cwd, { traceId: getTraceId(), outputPath: options.output }); | |
| } |
Identified by Warden find-warden-bugs · YJG-694
Adds
writeEmptyRunLog()call to auth error catch blocks in bothrunSkills()andrunConfigMode(), matching the pattern used by other early-exit paths (no skills matched, no files matched).Previously, when
verifyAuth()threw, the--outputfile was never written. Downstream consumers (sweep scripts, CI) that depend on the output file would fail or behave unexpectedly.Automated fix for Warden finding find-warden-bugs-9fff8c6a (high, detected by find-warden-bugs).
Ref #212