-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
[Bug]: beta.2 state migration creates agent_id index before adding column, blocking gateway startup #109867
Copy link
Copy link
Open
Labels
P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.Emergency: data loss, security bypass, crash loop, or unusable core runtime.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.Crash, hang, restart loop, or process-level availability failure.impact:ux-release-blockerA non-technical user is blocked without terminal, logs, config, or support.A non-technical user is blocked without terminal, logs, config, or support.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.no-staleExclude from stale automationExclude from stale automation
Description
Metadata
Metadata
Assignees
Labels
P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.Emergency: data loss, security bypass, crash loop, or unusable core runtime.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.Crash, hang, restart loop, or process-level availability failure.impact:ux-release-blockerA non-technical user is blocked without terminal, logs, config, or support.A non-technical user is blocked without terminal, logs, config, or support.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.no-staleExclude from stale automationExclude from stale automation
Type
Fields
Priority
None yet
Bug type
Regression (worked before, now fails)
Beta release blocker
No
Summary
After upgrading from
2026.7.2-beta.1to2026.7.2-beta.2, the shared SQLite migration creates indexes referencingmanaged_outgoing_image_records.agent_idbefore adding that column, sodoctor --fixfails withno such column: agent_idand the gateway cannot start.Steps to reproduce
2026.7.2-beta.1whose shared state database still has the pre-beta.2managed_outgoing_image_recordsshape (noagent_id,original_media_root, orcleanup_pendingcolumns).npm i -g [email protected].openclaw gateway restart.openclaw doctor --fix --non-interactiveas instructed by the error.Error: no such column: agent_id; the LaunchAgent remains stopped and port 18789 remains free.The affected table was empty in this reproduction, and
PRAGMA integrity_checkreturnedokbefore repair.Expected behavior
The beta.2 state migration should add the new additive columns before executing schema SQL that creates indexes using them, then complete the STRICT-table and operator-approval migrations. The gateway should restart normally.
Actual behavior
openclaw gateway restartandopenclaw doctor --fixboth fail on the same schema error. The service remains stopped and the dashboard is unreachable.The installed beta.2 code in
repairOpenClawStateDatabaseSchema()runs the canonical schema assertion/DDL beforeensureAdditiveStateColumns(). The canonical schema includes indexes on(session_key, agent_id, ...), while the additive step that addsmanaged_outgoing_image_records.agent_idruns later.OpenClaw version
2026.7.2-beta.2 (54d98a4)Operating system
macOS 27.0 (26A5378n), Apple Silicon
Install method
npm global (
npm i -g [email protected]), macOS LaunchAgentModel
Not model-dependent; failure occurs during state migration before the gateway accepts requests.
Provider / routing chain
Not applicable; local CLI -> shared SQLite state migration -> LaunchAgent gateway startup.
Additional provider/model setup details
No provider or model request is required to reproduce the failure.
Logs
Pre-repair table shape:
Verified recovery after taking a database backup:
Then:
Screenshots, recordings, and evidence
Direct CLI output and installed release code were inspected. No screenshot is required to observe the deterministic failure.
Impact and severity
Affected: installations upgrading to beta.2 with this legacy shared-state table shape.
Severity: high for affected installations because the gateway does not start and all dashboard/channel access is unavailable.
Frequency: reproduced on the affected database on every restart/doctor attempt until the missing columns were added.
Consequence: complete local gateway outage requiring manual SQLite repair.
Additional information
Last known working version on this state database:
2026.7.2-beta.1.First observed failing version:
2026.7.2-beta.2.Suggested fix: run
ensureAdditiveStateColumns(db)before any canonical schema assertion/DDL that creates indexes using additive columns, and add a migration fixture containing the exact pre-beta.2managed_outgoing_image_recordsschema. The fixture should verify thatdoctor --fixcompletes without manual SQL and results in schema version 3 withPRAGMA integrity_check = ok.