fix(configure): re-read config hash after persist to avoid stale-hash race (#64188)#66528
Conversation
Greptile SummaryThis PR fixes a Confidence Score: 5/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/commands/configure.wizard.ts
Line: 469-475
Comment:
**Unnecessary extra read — `err.currentHash` already holds the fresh hash**
`ConfigMutationConflictError` is thrown by `assertBaseHashMatches`, which reads the current snapshot inside `replaceConfigFile` and sets `err.currentHash` to the on-disk hash at that moment. Re-reading the file immediately after catching the error is an extra round-trip and a new window for another mutation to slip in between the throw and the re-read.
```suggestion
if (err instanceof ConfigMutationConflictError && attempt < maxRetries - 1) {
// Config was mutated (likely by a plugin during auth setup)
// Use the hash from the conflict error directly (already read inside replaceConfigFile)
currentBaseHash = err.currentHash ?? undefined;
continue;
}
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(configure): re-read config hash afte..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 61ba4e2b62
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
61ba4e2 to
c9bd29c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c9bd29c5d1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
b0c74e9 to
4915224
Compare
4915224 to
effe39d
Compare
effe39d to
0c4003a
Compare
|
Merged via squash.
Thanks @feiskyer! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0c4003a5be
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
… race (openclaw#64188) (openclaw#66528) Merged via squash. Prepared head SHA: 0c4003a Co-authored-by: feiskyer <676637+feiskyer@users.noreply.github.com> Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com> Reviewed-by: @vincentkoc
Summary
Fix
ConfigMutationConflictErrorwhen adding GitHub Copilot model viaopenclaw configure.The configure wizard reads the config snapshot hash once at start, but plugins (e.g. github-copilot) can mutate the config file during
promptAuthConfig(). WhenpersistConfig()then tries to write, the on-disk hash has changed → conflict error.Root Cause
persistConfig()used the initial hash for the first write, then setcurrentBaseHash = undefined— meaning:Fix
currentBaseHashinstead of setting it toundefinedTest
Added test case that simulates plugin mutation during wizard flow and verifies the retry path.
Closes #64188
Security Impact
Human Verification
pnpm test src/commands/configure.wizard.test.ts— 9/9 passedpnpm build— passed