fix(config): save empty config before clearing keychain entries#291
fix(config): save empty config before clearing keychain entries#291OwenYWT wants to merge 1 commit intolarksuite:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR adds a test verifying that config removal gracefully preserves existing config and keychain secrets when the save operation fails. It reorders the removal flow to save an empty config before deleting keychain items, with error propagation if the save fails. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Greptile SummaryThis PR fixes a correctness bug in Confidence Score: 5/5Safe to merge — the fix is correct and the single inline comment is a pre-existing non-blocking style note. All findings are P2 or lower; the save-before-cleanup reordering is logically sound and the regression test correctly validates the exact failure scenario introduced. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant CLI as config remove
participant Disk as Config File
participant KC as Keychain
CLI->>Disk: LoadMultiAppConfig()
Disk-->>CLI: original config (apps[])
CLI->>Disk: SaveMultiAppConfig(empty)
alt save succeeds
Disk-->>CLI: ok
loop for each app
CLI->>KC: RemoveSecretStore(appSecret)
CLI->>KC: RemoveStoredToken(appId, userId)
end
CLI-->>CLI: PrintSuccess
else save fails
Disk-->>CLI: error
CLI-->>CLI: return error (keychain untouched)
end
Reviews (1): Last reviewed commit: "fix(config): save empty config before cl..." | Re-trigger Greptile |
| for _, user := range app.Users { | ||
| auth.RemoveStoredToken(app.AppId, user.UserOpenId) | ||
| } |
There was a problem hiding this comment.
auth.RemoveStoredToken return value silently discarded
The error from auth.RemoveStoredToken is silently dropped. While RemoveSecretStore is explicitly documented as best-effort, RemoveStoredToken returns an error and callers elsewhere in the codebase may expect failures to be observable. Consider explicitly discarding like the rest of the cleanup pattern:
| for _, user := range app.Users { | |
| auth.RemoveStoredToken(app.AppId, user.UserOpenId) | |
| } | |
| _ = auth.RemoveStoredToken(app.AppId, user.UserOpenId) |
Summary
Prevent
config removefrom leaving config and keychain state inconsistent when saving the empty config fails.Changes
Test Plan
GOCACHE=/tmp/go-build-cache GOMODCACHE=/tmp/go-mod-cache /opt/homebrew/opt/go/bin/go test ./cmd/... ./internal/outputSummary by CodeRabbit
Bug Fixes
Tests