fix: Fix log level default and convert log.Info to ui.*/data.*#1959
fix: Fix log level default and convert log.Info to ui.*/data.*#1959
Conversation
Dependency Review✅ No vulnerabilities or license issues found.Scanned FilesNone |
b0a9e1f to
0019677
Compare
📝 WalkthroughWalkthroughRedirects user-facing messages from logger to UI/data channels and reduces log verbosity by changing several Changes
Sequence Diagram(s)(omitted — changes adjust output channels and logging defaults without introducing a new multi-component sequential flow) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1959 +/- ##
==========================================
+ Coverage 75.37% 75.43% +0.06%
==========================================
Files 792 792
Lines 73435 73516 +81
==========================================
+ Hits 55350 55460 +110
+ Misses 14574 14548 -26
+ Partials 3511 3508 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
ac9ae80 to
22ee4cd
Compare
…ui.* Fix regression where default log level changed from "Warning" to "Info" in pkg/flags/global_registry.go. Convert only result-oriented log.Info() calls to ui.* functions: - Validation success → ui.Success - Authentication success → ui.Success - Logout completion → ui.Success - Command listing output → data.Write - Dry-run file list → data.Writeln Keep informational/starting messages as log.Info (user doesn't need to see): - "Starting authentication..." - "Executing..." - "Running hooks..." - "Vendoring from..." Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Restore detailed logout debugging information (error counts, keychain status, identity/provider counts) as log.Debug while keeping ui.Success for user-facing confirmation messages. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2061f3c to
e4ec3c1
Compare
ui.Success() and ui.Successf() don't return values, so the `_ = ` prefix was causing build failures. Remove the assignments to fix CI builds. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@pkg/auth/manager_logout.go`:
- Around line 56-58: The code currently calls ui.Successf("Logout completed for
identity %s", identityName) unconditionally even when the function encountered
failures (errs non-empty); update the logout flow in pkg/auth/manager_logout.go
(the block using log.Debug, ui.Successf, vars errs, deleteKeychain,
identityName) so that ui.Successf is only invoked when there are no errors
(e.g., len(errs) == 0) and any other success flags (like deleteKeychain)
indicate true success; apply the same conditional change to the other two
occurrences around the blocks identified (the ones at the regions corresponding
to lines 172-174 and 231-233) so success is emitted only on true success and not
when errors are returned.
Move ui.Success/Successf calls after the error check so we don't mislead users by showing "completed" when the operation failed. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests to cover the data.Write/Writeln calls that were previously using log.Info: - TestPreCustomCommand_ShowsSubCommands: Tests the code path that displays available subcommands when a custom command has no arguments or steps but has subcommands (cmd_utils.go:433) - TestRunMainLogic_DryRun: Tests the dry-run mode of editorconfig validation which outputs file paths (validate_editorconfig.go:172) Both tests properly initialize the I/O context for the data package and follow existing patterns for mocking errUtils.OsExit. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@cmd/cmd_utils_test.go`:
- Around line 1773-1819: The test only asserts the exit code but doesn't verify
that preCustomCommand actually printed the subcommand names; also it must use
NewTestKit(t) to manage RootCmd state. Update
TestPreCustomCommand_ShowsSubCommands to call NewTestKit(t) at the start (use
the kit's I/O context instead of manually creating iolib.NewContext), initialize
the data writer via data.InitWriter(kit.IOCtx), run preCustomCommand as before,
then read the captured output from the test I/O buffer (the data writer / kit IO
context) and assert that the output contains "sub1" and "sub2"; keep the
existing OsExit mocking and panic handling around preCustomCommand. Ensure
references: TestPreCustomCommand_ShowsSubCommands, preCustomCommand, data.Write,
NewTestKit.
🧹 Nitpick comments (3)
cmd/cmd_utils_test.go (1)
1810-1818: Add assertion for unexpected non-exit scenario.If
preCustomCommandreturns without callingOsExit(a regression), this test would pass silently because no assertions run outside the recover block.♻️ Add fail-safe assertion
defer func() { if r := recover(); r != nil { // Expected: panic from mocked OsExit. assert.True(t, exitCalled, "OsExit should be called") assert.Equal(t, 1, capturedExitCode, "Should exit with code 1") } }() preCustomCommand(cmd, []string{}, parentCmd, commandConfig) + + // If we reach here, exit was not called - fail the test. + t.Fatal("preCustomCommand should have called OsExit but didn't") }cmd/validate_editorconfig_test.go (2)
80-81: Avoid hardcoded line numbers in comments.Line references will drift as the target file changes. Consider rephrasing to describe behavior instead of a line number.
♻️ Suggested tweak
-// This covers the data.Writeln(file) call at line 172. +// This covers the dry-run data output path.
82-126: Assert dry-run output, not just “no panic.”This test currently verifies only that
runMainLogic()doesn’t panic; it doesn’t validate the user-visible dry-run output. Consider capturing thedatawriter output and asserting it includes the discovered file path (e.g.,test.txt) to verify behavior. Based on learnings, ...
Address CodeRabbit review feedback: - Add NewTestKit(t) for RootCmd state cleanup per project guidelines - Capture stdout via os.Pipe() to verify actual output - Assert output contains "sub1" and "sub2" subcommand names - Previously only verified exit code, now validates full behavior Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
💥 This pull request now has conflicts. Could you fix it @osterman? 🙏 |
what
pkg/flags/global_registry.golog.Info()calls toui.Success()for user-visible outcomeslog.Info()calls todata.*()for pipeable outputwhy
pkg/flags/global_registry.gowithDefault: "Info"which conflicted withpkg/flags/global/flags.go:NewFlags()that correctly hadLogsLevel: "Warning". The registry default takes precedence, causing verbose logging.ui.Success()so they always display regardless of log level. Informational messages (starting, executing) correctly remain aslog.Info().references
Summary by CodeRabbit
New Features
Improvements
Tests
✏️ Tip: You can customize this high-level summary in your review settings.