fix(cli): t3 update checks the database before switching builds #37873
main fromrefs/pull/37873/head·merged by juliusmarminge View on GitHubProblem#
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
runStagedServicePreflightincloud/servicePreflight.ts. The in-app update andt3 updateboth call it. t3 updatenow 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 updatepasses 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.
- For an older target,
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-preflightbut 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-downgradewith 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.
- I started
main's server once, which migrated the new database to 96. Release 0.1.8 knows migrations up to 80. - Before, on
mainat4b758f49ec: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-preflighton the same database answered"status":"blocked".
- 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." - With the fix,
t3 update 0.1.8 --allow-downgradeinto an empty home still installs. - With the fix,
t3 update 0.1.10-nightly.20261116.4800on 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
| Delegate | Round 1 | Round 2 |
|---|---|---|
| Claude Opus | 8/10 | 9/10 |
| GPT Sol | 8/10 | 9/10 |
Claude Opus 5.5, an AI agent, on Jackson's behalf.
🤖 Generated with Claude Code
- 1
tanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
Approvability#
Verdict: Approved at
534d2b5Macroscope'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).juliusmarminge added labelstakeover:in-progress
Important
Review skipped#
Review was skipped as selected files did not have any reviewable changes.
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: d775f6b
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
bc079b4a-0b54-4d12-9068-8b782466a9ea
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_statustofalsein 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.tsThe 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.tsStaged 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.tsCLI 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 errorSuggested reviewers:
juliusmarminge,t3dotgg,saphid
Merge Risk:
Minimal · previous review534d2-
t3 updatenow 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:
4-
Check name Status Explanation Title check The title "fix(cli): t3 update checks the database before switching builds" names the main change. The changeset makes t3 updaterun the staged build's service preflight against the home's database …Description check 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 fi… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check 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 updaterun the staged build's service preflight against the home's database before switching builds, in place of the earlier--versioncheck. 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-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: 861211f
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
aa3d7284-01a8-4178-ac93-bf8099540081
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.tsapps/server/src/cli/update.tsapps/server/src/cloud/selfUpdate.tsapps/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.
-
-
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.Before After d775f6bff1 61766e237b 

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 · Transcript Recording · 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.
juliusmarminge added labelstakeover:ready
juliusmarminge removed labelstakeover:in-progress
juliusmarminge merged thisf68d970
juliusmarminge closed this
juliusmarminge removed labelstakeover:ready
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes