Skip to content

fix(init): debug log whoami fallback#223

Open
Lexiie wants to merge 1 commit into
TestSprite:mainfrom
Lexiie:fix/init-whoami-debug
Open

fix(init): debug log whoami fallback#223
Lexiie wants to merge 1 commit into
TestSprite:mainfrom
Lexiie:fix/init-whoami-debug

Conversation

@Lexiie

@Lexiie Lexiie commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Resubmission of #209 after the release-process hiccup closed it without merge.

Covers one src/commands/init.ts catch path from #186.

After setup successfully configures credentials, it runs a display-only whoami lookup to fill the final summary. If that lookup fails, setup intentionally continues with a placeholder summary. That behavior is fine, but the failure was completely silent, so --debug users could not tell why the summary fell back to no email / production / empty scopes.

This PR keeps default output and exit behavior unchanged, but emits a debug-only stderr line when the display-only identity lookup fails.

Changes

  • Capture the swallowed runWhoami error in runInit.
  • Emit [debug] setup identity lookup failed after configure: ... only when --debug is set.
  • Add a regression test that JSON stdout remains parseable while the debug line goes to stderr.

Verification

  • rtk vitest run src/commands/init.test.ts -t "debug log whoami fallback|whoami fallback|debug"
  • rtk npx eslint src/commands/init.ts src/commands/init.test.ts --fix-dry-run --format stylish
  • rtk npx eslint src/commands/init.ts src/commands/init.test.ts
  • rtk npm run typecheck

Refs #186

Summary by CodeRabbit

  • Bug Fixes
    • Improved init handling when identity lookup fails during setup, so the process still completes and prints a valid summary.
    • Added debug logging for lookup failures, while keeping JSON output clean and parseable.
    • Added coverage to verify the initialized status is still returned and debug messages appear only on stderr.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f42b7380-aba5-40df-926a-d9030a611af0

📥 Commits

Reviewing files that changed from the base of the PR and between 3305dfa and 5cff88a.

📒 Files selected for processing (2)
  • src/commands/init.test.ts
  • src/commands/init.ts

Walkthrough

Modifies error handling in runInit's whoami step to log a debug message when the identity lookup fails and debug mode is enabled, while retaining the existing placeholder fallback. Adds a corresponding unit test verifying stderr output and JSON stdout integrity.

Changes

Init Debug Logging

Layer / File(s) Summary
Debug error logging on identity lookup failure
src/commands/init.ts, src/commands/init.test.ts
runWhoami's catch block now captures the error and logs a debug message with the failure reason when opts.debug is true, falling back to a placeholder identity as before; a new test confirms stderr reports the failure while stdout remains valid JSON with status: 'initialized'.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding debug logging for the init whoami fallback.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant