Skip to content

fix(onboard): explain a gateway database with a modified migration - #9405

Open
udsy19 wants to merge 1 commit into
NVIDIA:mainfrom
udsy19:fix/9293-sqlite-migration-error
Open

fix(onboard): explain a gateway database with a modified migration#9405
udsy19 wants to merge 1 commit into
NVIDIA:mainfrom
udsy19:fix/9293-sqlite-migration-error

Conversation

@udsy19

@udsy19 udsy19 commented Aug 18, 2026

Copy link
Copy Markdown

Summary

A gateway database written by a newer OpenShell fails gateway start with one of two sqlx texts. Gateway start explains the is missing in the resolved migrations text and prints a named-database recovery, but passes the sibling has been modified text through verbatim, so that failure still names no database, no cause, and no remedy. Gateway start now classifies both texts as an incompatible gateway database and prints the same recovery, and the troubleshooting page names both texts.

Related Issue

Refs #9293

This change does not close #9293 on its own, and it intentionally uses no closing keyword. The literal text in that report, migration 6 was previously applied but is missing in the resolved migrations, is already classified on main: #8995 added classifyGatewayStartFailure and #8992 refined it. Neither is contained in v0.0.103, the release the reporter read the database with; both first ship in v0.0.109. The reported repro therefore no longer produces a raw migration error on a current release, and #9293 can be closed as fixed-in-release independently of this PR.

What remains is the sibling signature of the same defect. sqlx 0.8.6 — the version pinned by OpenShell's workspace Cargo.toml — reports a database written by a newer OpenShell through two MigrateError variants:

Variant Message
VersionMissing migration {0} was previously applied but is missing in the resolved migrations
VersionMismatch migration {0} was previously applied but has been modified

main classifies only the first. The second occurs on the same downgrade when the newer OpenShell rewrote an applied migration instead of appending one, and it still reaches the user verbatim. This PR closes that path.

Changes

  • src/lib/validation.ts: classifyGatewayStartFailure matches both sqlx signatures and returns database_migration_incompatible for each. The alternation is anchored to the shared migration N was previously applied prefix, so has been modified alone does not classify. The GatewayStartFailure doc names both signatures.
  • src/lib/onboard/docker-driver-gateway-failure.ts: the incompatible-database explanation now reads The database records a migration that this OpenShell version does not include, or defines with different contents. so it is accurate for both signatures. No other line of the recovery changes.
  • docs/reference/troubleshooting.mdx: the section covering this failure names both error texts, states what each one means, and is retitled from Reports a Missing Migration to Reports an Incompatible Migration. No page links to the previous heading.
  • src/lib/onboard/gateway-start-failure.test.ts: a classifier test for the modified-migration text, and a negative guard asserting that the file containing migration 6 has been modified on disk stays unknown.
  • src/lib/onboard/docker-driver-gateway-failure.test.ts: a reporter test asserting the modified-migration failure names the database file, the cause, and the archive-and-reonboard recovery.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: requesting maintainer sensitive-path review. As an outside contributor I cannot record a review of my own change. The change adds one alternation to an existing classifier and rewords one printed line; it adds no new command, path, credential handling, or process control, and the recovery command construction and its shell quoting are unchanged from fix(onboard): explain incompatible gateway database #8995.
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

DGX Station Hardware Evidence

  • Tested on DGX Station
  • Tested commit:
  • Station profile/scenario:
  • Result:
  • Supporting evidence:

Verification

  • PR description includes a Signed-off-by: line and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run validate:pr passed after refreshing origin/main when hooks were skipped or unavailable — hooks are not installed in this worktree; git fetch origin main && npm run validate:pr passed with zero problems.
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — command/result: npx vitest run --project cli src/lib/onboard/gateway-start-failure.test.ts src/lib/onboard/docker-driver-gateway-failure.test.ts → 39 passed, 3 new. Reverting only the two source files to origin/main and keeping the tests fails both new positive tests, so they pin the new behavior. npm run typecheck:cli → clean. npx oxlint on the four changed source files → no findings. npm run test:changed was not run to completion on this macOS host; its affected-test selection includes subprocess-spawning lanes that need the GNU utilities described under macOS Test Dependencies in CONTRIBUTING.md.
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — command/result: not run. This change is a focused onboarding diagnostic and adds no runtime or test-harness surface; the targeted CLI tests, typecheck:cli, oxlint, npm run docs, and npm run validate:pr cover the changed contracts.
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs builds without warnings (doc changes only) — npm run docsFound 0 errors and 2 warnings. Both warnings reproduce on the unmodified page set and are unrelated to this change.
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Follow-Up Observation

Not changed here, and offered only as a question for maintainers: classifyGatewayStartFailure has one non-test caller, reportDockerDriverGatewayStartFailure. A gateway start that terminates outside that reporter therefore never produces this diagnosis, even when the log carries either migration signature. If that is a gap worth closing rather than intended scoping, I am happy to open a separate issue.


Signed-off-by: Udaya Tejas udayatejas2004@gmail.com

Summary by CodeRabbit

  • Bug Fixes

    • Improved detection of incompatible gateway databases when applied migrations are missing or have changed.
    • Enhanced error messages to explain the issue, identify the database path, and recommend creating an .incompatible state directory.
    • Added clearer handling for migration-related gateway startup failures.
  • Documentation

    • Expanded troubleshooting guidance to cover both missing and modified migrations.

@copy-pr-bot

copy-pr-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ad3696ce-6a51-41d6-b75d-579b439302cb

📥 Commits

Reviewing files that changed from the base of the PR and between 2ddf676 and ab03ab4.

📒 Files selected for processing (5)
  • docs/reference/troubleshooting.mdx
  • src/lib/onboard/docker-driver-gateway-failure.test.ts
  • src/lib/onboard/docker-driver-gateway-failure.ts
  • src/lib/onboard/gateway-start-failure.test.ts
  • src/lib/validation.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/lib/onboard/docker-driver-gateway-failure.ts
  • src/lib/onboard/docker-driver-gateway-failure.test.ts
  • src/lib/validation.ts
  • docs/reference/troubleshooting.mdx
  • src/lib/onboard/gateway-start-failure.test.ts

Included review availability: Your plan includes up to 12 reviews per rolling hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Gateway startup now classifies modified applied migrations as incompatible database state. Onboarding errors and troubleshooting documentation describe both missing and modified migrations. Regression tests cover classification and recovery guidance.

Changes

Migration incompatibility diagnostics

Layer / File(s) Summary
Classify migration failures
src/lib/validation.ts, src/lib/onboard/gateway-start-failure.test.ts
classifyGatewayStartFailure now identifies modified applied migrations as database_migration_incompatible. Standalone on-disk migration edits remain unknown.
Report migration recovery guidance
src/lib/onboard/docker-driver-gateway-failure.ts, src/lib/onboard/docker-driver-gateway-failure.test.ts, docs/reference/troubleshooting.mdx
Gateway errors and troubleshooting guidance now cover migrations missing from or modified in the installed migration set. Tests verify the mismatch explanation and recovery guidance.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to ab03a

This PR improves gateway-start diagnostics for modified migrations and documents the recovery path; no actionable merge-blocking risk remains beyond normal checks and review.

Possibly related PRs

  • NVIDIA/NemoClaw#9151: Both changes update gateway-start failure classification and documentation.
  • NVIDIA/NemoClaw#9219: Both changes address OpenShell gateway database migration compatibility and recovery.

Suggested labels: bug-fix, area: onboarding, area: cli

Suggested reviewers: cv

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the primary change: explaining gateway database failures caused by modified migrations.
Linked Issues check ✅ Passed The changes satisfy issue #9293 by classifying migration incompatibility and providing the database path, cause, and recovery guidance.
Out of Scope Changes check ✅ Passed The documentation, diagnostics, and tests directly support the linked issue and PR objectives; no unrelated changes are evident.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — No blocking findings reported

Advisor assessment: No blocking advisor findings reported
Next action: No advisor follow-up needed.
Findings: 0 blockers · 0 warnings · 0 suggestions

Model lanes

  • GPT-5.6 Terra (primary): Completed · medium confidence · 0 blockers · 0 warnings · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Failed after a partial review · low confidence · 0 blockers · 0 warnings · 0 suggestions

Second-opinion terminology and E2E selections are advisory. Live E2E does not run automatically for pull requests.

1 semantic terminology decision

Terminology decisions are advisory. They affect the assessment only when a separate finding identifies concrete semantic impact.

  • justified — incompatible migration at docs/reference/troubleshooting.mdx:605: Keep "incompatible migration" in the heading and define both error cases in the following text.

E2E guidance

Advisory only. A maintainer can dispatch the default E2E suite for the commit under review.

Recommended E2E: None

Manual-only E2E: onboard-repair, onboard-resume, cloud-onboard
The manual PR workflow does not run these selectors for the commit under review. Run them from reviewed code on main.

Workflow run details

This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge.

@jyaunches jyaunches left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOC Reduction / Codebase Simplicity Review

Why this blocks

src/lib/onboard/docker-driver-gateway-failure.test.ts:181-209 adds a second recovery test with its own temporary directory, log write, reporter call, output collection, assertions, and cleanup. That recovery contract already exists at src/lib/onboard/docker-driver-gateway-failure.test.ts:147-179, and the reporter routes both sqlx texts through the same database_migration_incompatible branch. The signature-specific behavior is already pinned by the positive and false-positive classifier cases at src/lib/onboard/gateway-start-failure.test.ts:76-91. Keeping another full recovery scenario makes a one-alternation behavior change account for about 30 avoidable test lines and creates two places to maintain the same output contract.

Refactor direction

Delete the new reporter test. Change the existing recovery fixture at src/lib/onboard/docker-driver-gateway-failure.test.ts:155-157 to use the has been modified signature, then add the new diagnostic-text assertion to that test. The remaining reporter cases at lines 255, 286, 310, 340, and later continue to exercise the original missing-migration signature. Keep classifyGatewayStartFailure as the single owner of the two signature variants and printIncompatibleGatewayDatabaseRecovery as the single owner of their shared recovery.

Expected result

Both sqlx signatures, the false-positive guard, the database path, the archive command, and the recovery wording remain covered. The PR removes roughly 29 net lines and reduces the current net growth from 63 lines to about 34 without adding a helper or another abstraction.

sqlx reports a gateway database written by a newer OpenShell with one of
two texts. Gateway start explains "is missing in the resolved
migrations" but passed "migration N was previously applied but has been
modified" through verbatim, with no database path, cause, or remedy.
Classify both texts as an incompatible gateway database, print the same
named-database recovery, and name both texts in the troubleshooting
page.

Refs: NVIDIA#9293
Signed-off-by: Udaya Tejas <udayatejas2004@gmail.com>
@udsy19
udsy19 force-pushed the fix/9293-sqlite-migration-error branch from 4d1dca1 to ab03ab4 Compare August 18, 2026 05:35
@udsy19

udsy19 commented Aug 18, 2026

Copy link
Copy Markdown
Author

Thanks for the review. Applied as directed.

Deleted the second reporter test. The existing recovery test now writes the has been modified signature and asserts the new diagnostic sentence alongside the database path, the shell-quoted move, and the recovery wording. The remaining reporter cases still use the missing-migration signature. classifyGatewayStartFailure stays the only owner of the two signatures, and printIncompatibleGatewayDatabaseRecovery the only owner of their shared recovery.

Net growth is now 34 lines (43 added, 9 removed), down from 63.

I also rebased onto current main. The earlier codebase-growth-guardrails failure was a stale base: the branch still carried the pre-shrink test/nemoclaw-start.test.ts against the lowered budget on main. The guardrail passes locally now.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants