Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(cli): t3 update checks the database before switching builds #37873

MergedJacksondr5(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/37873/headmerged by juliusmarminge View on GitHub

Problem

t3 update stages the target build and only checks that it prints its version. So a move to an older build installs a build that doesn't know the database's newer migrations. That includes t3 update --channel stable --allow-downgrade, which docs/user/updating.md recommends when Stable is older than Nightly. The older server then starts with only a "Database migration history diverges" warning, on a database it doesn't understand. The in-app update already refuses this switch: it runs the staged build's __service-preflight against the database first.

Change

  • I moved the in-app update's staged preflight, unchanged, into runStagedServicePreflight in cloud/servicePreflight.ts. The in-app update and t3 update both call it.
  • t3 update now runs that check against this home's database in place of --version. The preflight also confirms the target's version.
    • A target that answers "blocked" is refused with its own reason.
    • A target whose check exits nonzero is refused with "could not confirm it supports this database".
    • Upgrades go through the same check.
  • Launcher protocol. After t3 update, the target runs under its own launcher, so only the database half of the check matters here.
    • For an older target, t3 update passes protocol 3. Every stable release since 0.0.43 accepts 3, and the 0.1.x stables accept only 3, so today's 4 would refuse all of them.
    • For any other target it passes today's protocol, which the in-app update already relies on new builds to accept.

Scope

This is a small fix for an obvious bug, so I didn't open an issue first: the CLI skips a check that the in-app update already runs for the same switch.

Limits I left as they are:

  • Releases 0.0.43 to 0.1.4 have __service-preflight but not its database check. They answer "ready" without looking, as they already do for the in-app update. A minimum version could refuse them instead.

  • A target that can't answer the check is refused. The alternative is to allow it under --allow-downgrade with a warning. I didn't build that.

  • A few targets are refused with a launcher-protocol message instead of a database answer:

    • a move down to the two 2026-11-11 nightlies that accept only protocol 4;
    • a preview cut before 2026-11-11 whose version sorts above the running build.

    Both refusals fail safe.

  • As with the in-app update, there is no flag to override a refusal.

Verification

I found it while checking how t3 update --allow-downgrade moves an install from Nightly back to Stable, and comparing it with the in-app update.

I reproduced it from source in a temporary T3 home, with no background service.

  1. I started main's server once, which migrated the new database to 96. Release 0.1.8 knows migrations up to 80.
  2. Before, on main at 4b758f49ec: t3 update 0.1.8 --allow-downgrade --base-dir <tmp> installed 0.1.8.
    • Started on that database, 0.1.8 logged "Database migration history diverges from this build" and began serving.
    • 0.1.8's own __service-preflight on the same database answered "status":"blocked".
  3. After, the same command on a copy of that database was refused, and nothing was left in runtime/versions. It printed: "This database has migrations that t3@0.1.8 does not know: 81_ProjectionMessageSearchText, … 96_RepairStaleTitleRegeneration. A newer build wrote them, and running t3@0.1.8 on this database is not safe. Stay on the newer release, or wait for a release that includes these migrations."
  4. With the fix, t3 update 0.1.8 --allow-downgrade into an empty home still installs.
  5. With the fix, t3 update 0.1.10-nightly.20261116.4800 on the migrated database installs. That is the upgrade path, with protocol 4.

Tests. update.test.ts gets a table of four cases:

  • an older target that accepts the database;
  • an older target that answers "blocked";
  • an older target whose check exits nonzero;
  • a newer target, which is checked with the current protocol.

All four fail on main and pass here. I also updated the existing pending-restart test's fake runner to answer the preflight. The selfUpdate and servicePreflight tests pass unchanged. vp run check:changed passes.

Not checked:

  • macOS or Windows.
  • A machine with the background service installed. The check runs before the service is touched.
  • The in-app update live. Its tests pass, and the extracted function runs the same steps.

Council review

Rounds: 2

DelegateRound 1Round 2
Claude Opus8/109/10
GPT Sol8/109/10

Claude Opus 5.5, an AI agent, on Jackson's behalf.

🤖 Generated with Claude Code

    1. tanstack-source added labelsbug

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. Approvability

      Verdict: Approved at 534d2b5

      Macroscope's review found this PR approvable — CLI updates now check database compatibility before switching builds, using the same preflight as server self-updates. The check reads migration history without modifying it and leaves the current build selected when validation fails.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. juliusmarminge added labelstakeover:in-progress

    5. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      Important

      Review skipped

      Review was skipped as selected files did not have any reviewable changes.

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between 534d2b5739b305312da70be725feb61d0fc30031 and 61766e237bd478457917ac0f2a510cdcbe1e8ca9.

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • Trigger review

      No actionable comments were generated in the recent review.

      Walkthrough

      Staged runtime validation now checks database compatibility through a shared preflight helper. Cloud self-update and CLI update use the helper, which validates the preflight result and target version.

      Changes: Staged Runtime Preflight

      Layer / File(s)Summary
      Shared staged-runtime preflight
      apps/server/src/cloud/servicePreflight.ts
      The new helper runs the pinned runtime preflight with the database path and launcher protocol. It validates process output, result shape, and target version, and raises a blocked-preflight error for a valid blocked result.
      Cloud self-update integration
      apps/server/src/cloud/selfUpdate.ts
      Staged runtime validation delegates to the shared helper instead of running and decoding the command locally.
      CLI update integration and tests
      apps/server/src/cli/update.ts, apps/server/src/cli/update.test.ts
      CLI update passes the database path and selects the launcher protocol based on the target version. Tests cover ready, blocked, unsuccessful, and newer-target preflight cases.

      Estimated code review effort: 3 (Moderate) | ~25 minutes

      Change: Bug fix

      Sequence Diagram(s)

      sequenceDiagram
        participant UpdateFlow
        participant Preflight
        participant Runner
        participant Runtime
        UpdateFlow->>Preflight: Pass runtime, target version, database path, and protocol
        Preflight->>Runner: Run pinned runtime preflight
        Runner->>Runtime: Execute __service-preflight with database path and protocol
        Runtime-->>Runner: Return preflight JSON
        Runner-->>Preflight: Return process result
        Preflight-->>UpdateFlow: Return ready or a preflight error

      Suggested reviewers: juliusmarminge, t3dotgg, saphid

      Merge Risk: Minimal · previous review 534d2

      t3 update now checks the target build against the home's database before switching, so downgrades into a database with newer migrations are refused. The shared helper keeps the CLI and in-app update behaving the same way. I found no merge-blocking risk.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title "fix(cli): t3 update checks the database before switching builds" names the main change. The changeset makes t3 update run the staged build's service preflight against the home's database …
      Description checkPassedThe description follows the repository template. It has Problem, Change, Scope, and Verification sections, and each section is filled in with specific detail. It explains the downgrade risk and the fi…
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Full details: Title check

      Explanation

      The title "fix(cli): t3 update checks the database before switching builds" names the main change. The changeset makes t3 update run the staged build's service preflight against the home's database before switching builds, in place of the earlier --version check. The title follows the conventional commit format the template recommends.

      Full details: Description check

      Explanation

      The description follows the repository template. It has Problem, Change, Scope, and Verification sections, and each section is filled in with specific detail. It explains the downgrade risk and the fix, links the reasoning to the in-app update, and gives reproduction steps, test results, and unchecked areas (macOS, Windows, live background service). The template's agent attribution line is present. The description does not link an issue. It explains why no issue was opened, which the template allows for small obvious fixes.

      Finishing Touches

      Generate unit tests (beta)

      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between 861211f215848f017167c9624ae262ef8a7acc01 and 534d2b5739b305312da70be725feb61d0fc30031.

      Files selected for processing: 4

      • apps/server/src/cli/update.test.ts
      • apps/server/src/cli/update.ts
      • apps/server/src/cloud/selfUpdate.ts
      • apps/server/src/cloud/servicePreflight.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

    6. Evidence

      Create a fresh home with the real server through migration 96, stop it, then run t3 update 0.1.8 --allow-downgrade --base-dir <home> and check the selected version. Linux x86_64; separately built standalone executables; synthetic data only. Captures render recorded CLI output with private paths redacted.

      BeforeAfter
      d775f6bff161766e237b
      Before: unsafe downgrade succeedsAfter: incompatible downgrade refused
      Exit 0; launcher selects 0.1.8. Target preflight reports blocked, but the installed target serves HTTP 200.Exit 1; explains unsupported migrations 81–96. Launcher remains on 0.1.10; database bytes unchanged.
      Recording · TranscriptRecording · Transcript

      Empty-home control: both commits successfully installed 0.1.8.

      Reproduction and seed driver · Recording renderer

      Not shown:

      • Preflight timeout, malformed response, and nonzero-exit failure branches were not exercised; the published 0.1.8 target returned a valid blocked response.
      • Background-service self-update paths affected by the shared preflight refactor were not exercised; this proof covers the standalone CLI update path.
    7. juliusmarminge added labelstakeover:ready

    8. juliusmarminge removed labelstakeover:in-progress

    9. juliusmarminge merged thisf68d970

    10. juliusmarminge closed this

    11. juliusmarminge removed labelstakeover:ready

Sign in to join this conversation.