Repository navigation
fix(auth): saving an API key for a new agent fails with a database identity error - #175656
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
|
Codex review: needs maintainer review before merge. What this changesThe PR lets auth-store candidates discovered before database creation adopt the newly created file identity. Example: Save an API key for a newly configured agent named probe.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep this PR open: it fixes a current-main credential-saving failure, preserves known-file replacement checks, and has no actionable review findings. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway credential operations discover agent auth stores, then use the existing readers and transaction owners to inspect or update credentials in SQLite. flowchart TD
A[Gateway API key request] --> B[Credential save owner]
B --> C[Candidate store discovery]
C --> D[Candidate identity check]
D --> E[Auth reader or writer]
E --> F[Agent SQLite database]
Technical reviewBest possible solution: Use this focused candidate-owner fix while retaining strict identity checks after a physical file is observed. Do we have a high-confidence way to reproduce the issue? Source shows discovery capturing a path identity and later checks rejecting legitimate database creation; the maintainer reports a matching Gateway reproduction, but this read-only review ran no target code. Is this the best way to solve the issue? The change belongs in the shared candidate owner, fixes all its read/write adapters, and preserves existing-file checks without adding creation-witness machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f63286335fb4. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +10, Tests +116. Total +126 across 2 files. Added test files: 0. View PR surface stats
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 17, 2026, 11:54 AM ET / 15:54 UTC. |
Saving an API key for a freshly configured agent failed with 'SQLite database path identity changed': candidate discovery recorded the agent database as absent, the Gateway then created it, and the later identity assertion rejected the new file. An absence snapshot protects no file, so the first check after the file appears adopts its identity; every later check stays strict, and a replaced known file is still rejected.
40437d5 to
71aa372
Compare
|
Merged via squash.
|
…penclaw#175656) Saving an API key for a freshly configured agent failed with 'SQLite database path identity changed': candidate discovery recorded the agent database as absent, the Gateway then created it, and the later identity assertion rejected the new file. An absence snapshot protects no file, so the first check after the file appears adopts its identity; every later check stays strict, and a replaced known file is still rejected.
Backport the exact candidate-store adoption contract from main #175656 for the release line. Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Fixes: saving an API key for a newly configured agent (Gateway
models.authSetApiKey, as used by onboarding, the Control UI, and live suites) fails withUNAVAILABLE: SQLite database path identity changed: …/agents/<id>/agent/openclaw-agent.sqlitewhen that agent's database does not exist yet.User Impact
User impact: storing credentials for a fresh agent succeeds instead of failing the first time. Integrity checks for existing agent databases are unchanged: a known database file that gets replaced is still rejected.
Why This Change Was Made
Candidate auth-store discovery records each candidate database's identity. For a fresh agent that identity is "absent at this path". The same Gateway then creates the database, either in the operation itself or through concurrent startup work, and the later identity assertion rejects the file that now exists. The capture/check pair came from #166183.
An absence snapshot protects no file. So the first check after the file appears adopts its identity once, and every later check (including candidates discovered as existing files) stays strict. The Gateway owns these databases, so a foreign writer creating the file in that window is not a supported concurrent case. That trade is noted in the code.
A first attempt only accepted files created by the same operation's execution owner. Under host load it still failed intermittently when startup work created the database first. The second commit replaces that with the simpler rule and removes the owner-witness plumbing, leaving a net diff of 2 files.
Evidence
models.authSetApiKeyfailed with the identity error. After, 8/8 consecutive runs succeed, movingpath:→file:with zero inference requests.src/gateway/gateway-cron-tools-allow.live.test.tsused to fail its OpenClaw-harness case with this identity error on main and on the first attempt. It now passes both cases (OpenClaw 173s, Codex 188s).gateway-cron-placement.live.test.tsstill fails with an unrelated "forced cron run did not publish its completion record", the same as before this change.candidate-stores.test.tscovers creation before and during first use, replacement after adoption, and replacement of a file discovered as existing (37 tests with the creation-witness suite).