Skip to content

fix: start gateway after upgrading provider configuration - #200596

Merged
RomneyDa merged 3 commits into
mainfrom
openclaw/vivid-crab
Nov 17, 2026
Merged

RomneyDa merged 3 commits into
mainfrom
openclaw/vivid-crab

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #200583

What Problem This Solves

After upgrading from 2026.11.4, the first Gateway start can fail with "required secrets are unavailable" and a SQLite disk I/O error when a model provider is configured. A provider entry is enough; an API key is not required.

User Impact

The Gateway can complete that first start without retaining a database connection to the removed upgrade copy. No configuration changes or new migration are required.

Why This Change Was Made

Config validation opens metadata readers on the upgrade copy. Renaming the database leaves those readers holding SQLite's old pathname. Close them through the existing database cleanup owner before the copy is published or removed, including when validation throws.

Evidence

  • All 13 targeted upgrade tests passed before and after pr-simplify on main eceb208abea1edafdc076f101330fb13b8392743. The two regressions cover provider entries with and without a key, real config validation, native readers, publication, WAL reopening, and the subsequent auth-store read. Only the Doctor schema-stamp operation is mocked.
  • The state/logging test typecheck, lint for both changed files, formatting, and git diff --check passed. No changes outside this fix were needed.
  • Earlier, on base 8d0f33f6b405, both regressions failed with SQLite 1802 without the fix and passed with it. A real Linux 2026.11.4-to-patched startup returned HTTP 200 from health, startup, and readiness endpoints. That live run was not repeated on the refreshed base; macOS and the full suite were not run.
  • pr-simplify removed nothing. The complete change adds 8 net production lines and 81 test lines, with no new helper, retry, or cache.
  • Independent snapshot-based review found no actionable defects in the unchanged fix. Two subsequent Auto Review attempts were interrupted without a validated report; they are not counted as clean reviews.
Focused verification commands
OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs src/state/state-upgrade-startup.test.ts src/state/state-upgrade.test.ts --maxWorkers=1
node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.state-logging.json --noEmit
node scripts/run-oxlint.mjs --tsconfig test/tsconfig/tsconfig.core.test.state-logging.json src/state/state-upgrade-startup.ts src/state/state-upgrade-startup.test.ts
OPENCLAW_FORMAT_TOOL=oxfmt pnpm format:check src/state/state-upgrade-startup.ts src/state/state-upgrade-startup.test.ts
git diff --check

Co-authored with Dan.

Co-authored-by: daniel-lxs [email protected]

Work sessions

Linked for team reference; these sessions aren’t public.

Worked on by

roboclaw-bot and others added 3 commits November 17, 2026 12:31
Co-authored-by: daniel-lxs <[email protected]>
Worked on by:
- @daniel-lxs

Co-authored-by: daniel-lxs <[email protected]>
OpenClaw-Publication: 58bf1c34-4048-40fa-bb3e-37c4e52c2018
@clawsweeper

clawsweeper Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 17, 2026
@clawsweeper

clawsweeper Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Close temporary database readers after upgrade configuration validation, before publishing or discarding the upgrade copy.

Example: Upgrade v2026.11.5 state containing models.providers.openai without an API key.

  • Before: The first Gateway start can exit with a secrets-wrapped SQLite disk I/O error.
  • After: Temporary readers close before publication, allowing the first start to reach readiness.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A minimal, correct repair with meaningful regression coverage and a controlled latest-stable upgrade comparison; shipped proof used matching patched files on another main revision.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The public macOS report exercises first Gateway startup after a v2026.11.5 upgrade with a keyless OpenAI provider: unchanged source fails, while source 3447bee plus hash-matching PR files reaches readiness and preserves the checked data. This resolves the previous compatibility blocker. The run used another main revision rather than the exact PR head; the compared startup, upgrade, and cleanup owners show no additional differences affecting this repair. Reminder execution was outside the tested scenario.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: The first Gateway start after an upgrade can fail despite valid provider configuration.
Reason: The maintainer-authored direction restores successful startup without adding settings, changing defaults, or weakening configuration admission.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

This maintainer-authored PR fixes a current Gateway startup regression with a focused lifecycle repair; no actionable code defects were found.

Priority: P1
Reviewed head: da259d41d62e90a9ba3ed3690fbc2dc60df49508

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway bootstrap upgrades older state in a private copy, validates configuration, and publishes the result before runtime secrets preparation opens the database.

flowchart TD
  A[Gateway bootstrap] --> B[Copy and upgrade state]
  B --> C[Validate configuration]
  C --> D[Drain temporary database readers]
  D --> E[Publish or discard copy]
  E --> F[Open runtime state and prepare secrets]
Loading

Technical review

Best possible solution:

Retain the path-scoped finally cleanup through the existing database lifecycle owner.

Do we have a high-confidence way to reproduce the issue?

The linked report supplies concrete upgrade steps and SQLite error 1802, and source confirms provider metadata readers surviving publication; this read-only review executed no target code.

Is this the best way to solve the issue?

This is the smallest complete fix: release temporary readers before their database moves while retaining configuration validation, publication ordering, and the existing cleanup owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 22614d5b0e81.

Provenance checked

  • Startup upgrade configuration admission keeps the original intent (ef930eb: Validate upgraded configuration before publication so a refused start leaves the previous package's state readable.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit ef930eb adds src/state/state-upgrade-startup.ts:68 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ef930ebbad77; files: src/state/state-upgrade-startup.ts)

PR surface

Source +8, Tests +81. Total +89 across 2 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 24 16 +8
Tests 1 81 0 +81
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 105 16 +89

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +8 net lines; tests +81 lines Growth is justified by a focused cleanup boundary and regression coverage exercising real configuration reads, publication, WAL reopening, and subsequent auth-state access.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P1: The upgrade defect terminates the first Gateway start before readiness and interrupts service until another start.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-17T13:27:06.247Z sha da259d4 :: blocked before merge. :: none

Reviewed November 17, 2026, 9:10 AM ET / 14:10 UTC (Revision 2).

@daniel-lxs

Copy link
Copy Markdown
Member

Verified the latest-stable upgrade in a throwaway macOS 26.6.2 arm64 VM with Node 24.22.1. Installed published 2026.11.5, configured models.providers.openai without an API key, and saved a labeled session, a disabled reminder, and a workspace file. Both upgrades used copies of the same stopped stable-state snapshot.

The tested source was 3447bee3a310a3c69d1252dde8545f7db629c5a8 plus this PR's two-file fix from da259d4, not the exact PR head. Both patched files matched the PR's file hashes. Packaging the exact head failed on missing runtime-worker-loader.mjs, matching the existing packaging report.

  • Unchanged 3447bee: first start exited 1 before readiness with Startup failed: required secrets are unavailable. Error: disk I/O error | ERR_SQLITE_ERROR. Numeric 1802, the underlying stack, and the shadow database pathname were not captured. The secrets wording wraps the SQLite failure; the provider configuration has no key requirement for startup.
  • 3447bee plus this fix: first start reached readiness in 34.3 seconds. /readyz, /healthz, and /startupz all returned HTTP 200; readiness reported ready: true, coreReady: true, and no failing components.
  • Provider configuration, timezone, Gateway settings, workspace file checksum, session ID and label, and disabled reminder ID, schedule, and payload matched stable. Shared-state schema upgraded from 36 to 40 and agent schema from 38 to 42. All five SQLite databases returned integrity_check: ok.

Reminder execution was not tested. The VM was destroyed and the one-shot launchd job was removed.

@daniel-lxs

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Nov 17, 2026
@RomneyDa
RomneyDa merged commit 9aed362 into main Nov 17, 2026
156 checks passed
@RomneyDa
RomneyDa deleted the openclaw/vivid-crab branch November 17, 2026 17:21
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 18, 2026
…00596)

* Save workspace before refreshing its selected base

Co-authored-by: daniel-lxs <[email protected]>

* fix: start gateway after upgrading provider configuration

Worked on by:
- @daniel-lxs

Co-authored-by: daniel-lxs <[email protected]>
OpenClaw-Publication: 58bf1c34-4048-40fa-bb3e-37c4e52c2018

---------

Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: daniel-lxs <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 18, 2026
* Save workspace before refreshing its selected base

Co-authored-by: daniel-lxs <[email protected]>

* fix: start gateway after upgrading provider configuration

Worked on by:
- @daniel-lxs

Co-authored-by: daniel-lxs <[email protected]>
OpenClaw-Publication: 58bf1c34-4048-40fa-bb3e-37c4e52c2018

---------

Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: daniel-lxs <[email protected]>

(cherry picked from commit 9aed362)

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

First Gateway start after upgrading from 2026.11.4 fails with SQLite I/O error; restart recovers

3 participants