-
Couldn't load subscription status.
- Fork 242
fix: prevent keyring backend override by reading client.toml first #448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Dependency Reviewβ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
π WalkthroughWalkthroughThe root command initialization flow is reorganized to apply configuration reads in a new sequence: HomeDir flags are processed first, followed by client config reading to override initial context values, ensuring config-file values take precedence, with a duplicate config read call removed. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Root as Root Command
participant Ctx as Client Context
participant Config as Config File
rect rgb(220, 240, 220)
Note over Root,Config: NEW INITIALIZATION ORDER
Root->>Root: Read HomeDir from flags
Root->>Config: ReadFromClientConfig
Config-->>Ctx: Override initClientCtx with config values
Root->>Root: Apply persistent command flags
Root->>Ctx: Apply keyring override
Root->>Ctx: Complete client context setup
end
Estimated code review effortπ― 2 (Simple) | β±οΈ ~10 minutes Poem
Pre-merge checks and finishing touchesβ Failed checks (1 inconclusive)
β Passed checks (2 passed)
β¨ Finishing touches
π§ͺ Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
π§Ή Nitpick comments (1)
cmd/initiad/root.go (1)
166-166: Consider handling the error from ReadFromClientConfig.The error return value is silently ignored here. While the
PersistentPreRunEhook (line 119-122) will catch config read errors for command execution, ignoring it here for autocli setup could mask configuration issues during initialization.Consider handling the error for consistency:
- initClientCtx, _ = config.ReadFromClientConfig(initClientCtx) + if initClientCtx, err := config.ReadFromClientConfig(initClientCtx); err != nil { + // Log or handle error appropriately for autocli setup + }Alternatively, if the error is intentionally ignored for best-effort autocli configuration, a comment explaining this would be helpful.
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
π Files selected for processing (1)
cmd/initiad/root.go(1 hunks)
β° Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Run test and upload codecov
- GitHub Check: golangci-lint
- GitHub Check: Analyze (go)
π Additional comments (2)
cmd/initiad/root.go (2)
112-116: LGTM! Home directory correctly set before reading client config.The logic ensures the home directory is properly set before reading the client config file, which is essential for loading the correct
client.toml.Minor observation: The check
initClientCtx.HomeDir == ""appears defensive sinceinitClientCtxis initialized withDefaultNodeHome(line 93), andreadEnv(line 369-371) only updates it when non-empty. The primary useful condition iscmd.Flags().Changed(flags.FlagHome). However, this defensive check doesn't harm functionality.
118-122: Configuration read order is correctly implemented and achieves the PR objective.The code at lines 118-122 properly reads
client.tomlafter setting the home directory but before applying persistent command flags. The initialization sequence in the PreRunE hook is correct:
- Home directory is set (lines 113-115)
- Client config is read from
client.toml(lines 118-122)- Persistent command flags are applied (lines 125-128), allowing them to override config values
- The keyring backend flag is marked as unchanged (lines 144-146) to prevent inner commands from inadvertently overriding it
The secondary
ReadFromClientConfigcall at line 166 serves a different purpose (initializing autocli options for the root command structure) and does not conflict with this per-command flow.
Codecov Reportβ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #448 +/- ##
=======================================
Coverage 40.47% 40.47%
=======================================
Files 307 307
Lines 28458 28458
=======================================
Hits 11518 11518
Misses 15157 15157
Partials 1783 1783 π New features to boost your workflow:
|
Description
Closes: #XXXX
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!in the type prefix if API or client breaking changeReviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...