Skip to content

[Bug]: Container image upgrades skip openclaw upgrade migrations before gateway startup #98565

Closed

Description

@jacobtomlinson

Bug type

Upgrade lifecycle gap

Summary

Container image upgrades can bypass the migrations that normally run through openclaw upgrade.

When an operator replaces one OpenClaw container image with another while preserving the same state/config volume, the container starts the gateway directly. Startup may run limited config/state preflight work, but it does not detect that the OpenClaw version changed and run the pending versioned upgrade migrations before declaring the gateway ready.

This means any migration added between image versions can be skipped for common Docker/Kubernetes-style upgrades.

Expected behavior

On gateway startup, OpenClaw should detect when the current OpenClaw version differs from the last successfully migrated version for the mounted state/config.

Before gateway readiness, it should either:

  • run all pending openclaw upgrade migrations for that version transition, then record the successful migrated version; or
  • fail readiness with a clear, actionable error if those migrations cannot safely run.

The startup path should be idempotent, locked against concurrent starts, and should not report a healthy gateway while required upgrade migrations are still pending.

Actual behavior

Replacing the container image starts the gateway without running the full upgrade migration path.

A recent 2026.6.10 -> 2026.6.11 container replacement exposed this through a configured Mattermost channel not being converged after upgrade. That is only the example. The Mattermost-specific activation/repair bug is tracked separately in #98564.

The broader issue here is that container image replacement does not automatically execute the migrations that openclaw upgrade would have run.

Steps to reproduce

  1. Run an OpenClaw container at version N with state/config mounted.
  2. Configure state that requires a migration in version N+1.
  3. Stop/remove only the container, preserving the mounted state/config.
  4. Start a version N+1 OpenClaw container normally.
  5. Observe that the gateway starts without eagerly running the full upgrade migration path for N -> N+1.

Impact

This affects users who upgrade by replacing container images, which is the normal upgrade model for Docker and Kubernetes deployments.

Depending on the skipped migration, the result can be missing plugins, stale config, inconsistent state, broken channels, missed messages, or other release-specific failures. The gateway can appear ready even though the mounted state has not been upgraded for the current image.

Non-goal

This issue should not track the Mattermost-specific activation behavior. Keep that in #98564. Mattermost is useful only as a concrete example showing why skipped container-upgrade migrations are dangerous.

Acceptance criteria

  • Startup records and compares the last successfully migrated OpenClaw version for the mounted state/config.
  • A version change runs the same migration set expected from openclaw upgrade before gateway readiness.
  • Migration execution is idempotent and protected from concurrent startup races.
  • Migration failures prevent healthy readiness and produce actionable logs.
  • Tests cover a container-style upgrade path where the gateway starts directly after an image version change.

Activity

  1. added
    bugSomething isn't working
    regressionBehavior that previously worked and now fails
    on Jul 1, 2026
  2. clawsweeper commented on Jul 1, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 4, 2026, 10:56 PM ET / 02:56 UTC.

    Summary
    Keep open: current main still treats direct container image replacement as a gateway startup path, not as an update/finalize path, so the reported 2026.6.10 to 2026.6.11 migration gap remains a real upgrade/readiness problem despite adjacent Mattermost and config-health fixes.

    Reproducibility: yes. the issue discussion includes a live official-image 2026.6.10 to 2026.6.11 container swap where the default gateway command became healthy while version metadata and doctor output still showed pending migration work.

    Root-cause cluster
    Relationship: canonical
    Canonical: #98565
    Summary: This issue is the remaining canonical container-upgrade readiness/migration contract problem; related Mattermost activation and macOS config-health reports cover narrower symptoms or adjacent second-writer cleanup.

    Members:

    Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

    Next step
    The bug is live-reproduced, but protected maintainer labels and the startup-versus-doctor/update policy choice make this a maintainer design decision rather than a safe automatic fix PR.

    Review details

    Best possible solution:

    Define a maintainer-owned container upgrade contract that records the last successfully migrated OpenClaw version and either runs only safe idempotent pending migrations under a startup lock before readiness or fails readiness with an actionable in-product repair path.

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

    Yes: the issue discussion includes a live official-image 2026.6.10 to 2026.6.11 container swap where the default gateway command became healthy while version metadata and doctor output still showed pending migration work.

    Is this the best way to solve the issue?

    Unclear until maintainers decide the startup policy: source evidence supports the bug, but the best fix must choose which migrations are safe before readiness versus which should hard-fail with a repair path.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The correct fix crosses startup readiness, doctor/update migration ownership, package-manager policy, and idempotent upgrade locking, so a small automatic patch could either run unsafe repair work on startup or leave the readiness false-positive intact.

    Codex review notes: model internal, reasoning high; reviewed against b34c188f8f0d.

    Label changes

    Label changes:

    • add impact:ux-friction: Operators currently have to inspect logs, config metadata, or doctor output to discover that readiness did not mean upgrade repair completed.
    • add issue-rating: 🦀 challenger crab: Current issue advisory state selects this label.
    • add clawsweeper:current-main-repro: Current issue advisory state selects this label.
    • remove clawsweeper:needs-live-repro: Current issue advisory state no longer selects this label.
    • remove issue-rating: 🐚 platinum hermit: Current issue advisory state no longer selects this label.

    Label justifications:

    • P1: The issue affects real container upgrades where the gateway can report healthy while channel/plugin migrations remain pending and messages may be missed.
    • impact:message-loss: The reported failure mode can leave upgraded channel plugins unloaded while the gateway is ready, so inbound channel messages are not consumed.
    • impact:ux-friction: Operators currently have to inspect logs, config metadata, or doctor output to discover that readiness did not mean upgrade repair completed.
    • impact:other: The core upgrade/readiness contract is affected beyond a single channel, including version-transition detection and startup migration ownership.
    • maturity:stable: The affected gateway lifecycle and CLI install/update/doctor surfaces are M4 stable in the repository maturity scorecard.
    Evidence reviewed

    What I checked:

    • Live reproduction in issue discussion: A 2026-07-03 comment reports an official GHCR 2026.6.10 to 2026.6.11 image swap with the same volume and default image command where /healthz became ready while meta.lastTouchedVersion stayed at 2026.6.10 and doctor still reported pending legacy-state work.
    • Container starts the gateway directly: The Docker image healthcheck targets /healthz and the default command launches node openclaw.mjs gateway, so a direct image replacement enters the gateway path rather than an update/finalize command. (Dockerfile:347, b34c188f8f0d)
    • Gateway fast path runs bootstrap before server load: The gateway command prepares and rechecks guarded startup bootstrap state before loading the server, but this source path does not establish a full versioned upgrade/finalize contract. (src/cli/run-main.ts:190, b34c188f8f0d)
    • Gateway preflight intentionally skips legacy config repair: ensureConfigReady runs doctor config preflight with migrateState: true and migrateLegacyConfig: false, matching the observed startup state-migration subset rather than full doctor repair. (src/cli/program/config-guard.ts:190, b34c188f8f0d)
    • Full doctor flow owns repair mode: The doctor config flow starts from preflight and then applies repair behavior when --fix/--yes is selected, which is separate from gateway readiness on direct image startup. (src/commands/doctor-config-flow.ts:138, b34c188f8f0d)
    • Config version marker only updates on config writes: meta.lastTouchedVersion is stamped from the current package version when config is written, so gateway startup alone does not record that an image-version transition completed. (src/config/io.meta.ts:16, b34c188f8f0d)

    Likely related people:

    • openperf: Merged PR 93118 changed the gateway fast-path startup migration/bootstrap surface that this issue now exercises. (role: recent gateway startup migration contributor; confidence: high; commits: df521a645977; files: src/cli/gateway-cli/pre-bootstrap.ts, src/cli/run-main.ts)
    • fuller-stack-dev: Merged PR 91586 worked on package update continuation and post-install doctor warning behavior adjacent to direct-upgrade finalization semantics. (role: recent update/package doctor contributor; confidence: medium; commits: 7259cb5c771b; files: src/infra/update-post-core-finalize.ts, src/infra/package-update-steps.ts)
    • joshavant: Merged PR 82859 repaired configured plugins during legacy upgrades, an adjacent migration/doctor repair path implicated by the Mattermost upgrade symptom. (role: configured plugin repair contributor; confidence: medium; commits: ab2943e2ff9c; files: src/commands/doctor/repair-sequencing.ts, src/config/plugin-auto-enable.shared.ts)
    • 849261680: Merged PR 96397 added warnings for configured channel plugins that cannot load at gateway startup, which improves visibility but does not solve the readiness/migration gate. (role: adjacent gateway startup diagnostics contributor; confidence: medium; commits: 16b275a0fba7; files: src/gateway/server-startup-log.ts, src/gateway/server-startup-post-attach.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  3. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.
    maturity:stableBroken existing behavior primarily owned by an M4/M5 scorecard surface.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.
    on Jul 1, 2026
  4. changed the title [-][Bug]: Container image upgrades skip configured-plugin convergence before gateway ready[/-] [+][Bug]: Container image upgrades skip openclaw upgrade migrations before gateway startup[/+] on Jul 1, 2026
  5. jacobtomlinson commented on Jul 1, 2026

    @jacobtomlinson
    ContributorAuthor
  6. clawsweeper commented on Jul 1, 2026

    @clawsweeper
    Contributor

    🦞🧹
    ClawSweeper re-review requested.

    I asked ClawSweeper to review this item again.
    Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
    Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

  7. AmirF194 commented on Jul 3, 2026

    @AmirF194
    Contributor

    Live repro for the needs-live-repro gate, using the exact image-swap flow from the issue's steps (macOS host, Docker Desktop; official GHCR images).

    Setup

    • ghcr.io/openclaw/openclaw:2026.6.10 (sha256:af7ea052cf21…) and :2026.6.11 (sha256:3814fb1f62f9…), one shared state volume mounted at /home/node/.openclaw, OPENCLAW_GATEWAY_TOKEN via env, default image CMD (node openclaw.mjs gateway, Dockerfile:350).
    • Init at N: config set gateway.mode local via the 6.10 CLI → meta.lastTouchedVersion: "2026.6.10"; ran the 6.10 gateway once to healthy, stopped it, replaced only the image with 6.11 (volume preserved), started normally.

    Observed on the 6.11 boot (same volume)

    1. No version transition is detected or recorded. Startup logs contain no version-change/migration-pending acknowledgment, and after the 6.11 gateway reached ready + healthz OK (~4s), the state still said meta.lastTouchedVersion: "2026.6.10". Only running openclaw doctor --fix inside the container advanced it to "2026.6.11" — so the recorded-version mechanism exists, but only on the CLI repair path that container upgrades never execute.
    2. Startup runs only the generic auto-state-migration pass, not the doctor repair set. The boot auto-migrated update-check.json → shared SQLite (that pass is not version-gated), but seconds after healthz went green, read-only openclaw doctor --lint on the same state returned "ok": false with a pending core/doctor/legacy-state finding: Config health state: legacy JSON file → shared SQLite state — Run 'openclaw doctor --fix' to migrate legacy state.
    3. Ready is reported with migrations pending, persistently. The skipped migration is warned about and then ignored: [state-migrations] Legacy state migration warnings: Left legacy config health state in place because 1 entry conflicts with shared SQLite state: /home/node/.openclaw/logs/config-health.json — and the same warning re-appears on every subsequent healthy restart of the 6.11 container.

    Startup log excerpt from the first 6.11 boot:

    [state-migrations] Auto-migrated legacy state:
    - Migrated update-check state → shared SQLite state
    [state-migrations] Legacy state migration warnings:
    - Left legacy config health state in place because 1 entry conflicts with shared SQLite state: /home/node/.openclaw/logs/config-health.json
    …
    [gateway] ready            # ~1s later; healthz OK; lastTouchedVersion still 2026.6.10
    

    Secondary observation (cross-ref, not this issue's scope): the config-health.json legacy conflict above was produced organically by the 6.10 gateway's own writes, and it survives even openclaw doctor --fix --non-interactive under 6.11 (same "left in place" warning). That convergence gap looks like the #98917 cluster; mentioning it here only because it means the pending-migration state in observation 2/3 is not even operator-recoverable non-interactively.

    (Excluded from the findings: core/doctor/skills-readiness warnings from doctor --lint, which are just missing optional binaries in the slim container, and the Mattermost specifics per the issue's non-goal.)

    This matches the acceptance criteria's premise: nothing on the container startup path compares lastTouchedVersion against the running image version or runs the doctor/upgrade migration set before readiness. Evidence only — the fix shape stays with maintainers per the needs-product-decision label. Happy to re-run variations (different version pairs, k8s-style restart loops, --fix posture comparisons) if useful.

    AI-assisted (Claude Code): all commands executed live as described; logs and state diffs captured from the actual containers.

  8. added
    impact:ux-frictionUser-facing flow adds avoidable confusion or support burden without fully blocking progress.
    issue-rating: 🦀 challenger crabExceptional issue quality: high-confidence current-main reproduction and actionable evidence.
    clawsweeper:current-main-reproClawSweeper found a high-confidence current-main issue reproduction.
    and removed
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    on Jul 5, 2026
  9. locked as resolved and limited conversation to collaborators on Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.bugSomething isn't workingclawsweeper:current-main-reproClawSweeper found a high-confidence current-main issue reproduction.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.impact:ux-frictionUser-facing flow adds avoidable confusion or support burden without fully blocking progress.issue-rating: 🦀 challenger crabExceptional issue quality: high-confidence current-main reproduction and actionable evidence.maintainerMaintainer-authored PRmaturity:stableBroken existing behavior primarily owned by an M4/M5 scorecard surface.regressionBehavior that previously worked and now fails

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions