Skip to content

fix(cli): fail loudly when turso/libSQL is selected in the open-core CLI (#3276 follow-up)#3292

Merged
os-zhuang merged 1 commit into
mainfrom
fix/cli-turso-loud-error
Jul 19, 2026
Merged

fix(cli): fail loudly when turso/libSQL is selected in the open-core CLI (#3276 follow-up)#3292
os-zhuang merged 1 commit into
mainfrom
fix/cli-turso-loud-error

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Stacked on #3285 (base = fix/cli-memory-driver-dispatch). It builds on the storage-driver.ts file that PR introduces. Merge #3285 first, then this retargets cleanly to main. Review just the top commit / the diff-vs-base.

Problem

The same "declared ≠ enforced" bug as #3276, for turso/libSQL:

  • os dev (dev.ts:89) and os start (start.ts:100) advertise turso as a --database-driver option, and libsql:// URLs in help/examples.
  • inferDriverTypeFromUrl maps libsql:// and *.turso.* URLs to driver kind turso.
  • But the driver dispatch had no turso branch — so selecting it (via OS_DATABASE_DRIVER=turso, --database-driver turso, or a libsql:// URL) silently fell through to the SQLite default and ignored the requested remote libSQL connection.

Why not just "add a turso driver" (option a)

Investigated: @objectstack/driver-turso is a cloud / EE package (../cloud/packages/driver-turso) — it extends SqlDriver over @libsql/client, is composed by the cloud runtime's own kernel factory (cloud-stack.ts / environment-kernel-factory.ts do new TursoDriver({ url, authToken })), and its spec schema lives in the cloud package specifically to keep it out of open-core @objectstack/spec. runtime/standalone-stack.ts explicitly stopped consuming its auth token. So turso is deliberately not an open-core engine — pulling it into open-core's dispatch would reintroduce the coupling the architecture removed.

Fix (option b, refined — recognize + fail loud)

  • createStorageDriver throws a typed UnsupportedDriverError for turso/libsql, with an actionable message (names @objectstack/driver-turso, explains cloud/EE vs. explicit config, lists the open-core alternatives).
  • serve.ts re-throws it from the driver block's catch so run()'s existing fatal handler restores output, prints the message, and exits 1 (dev AND prod) — never a silent SQLite boot.
  • inferDriverTypeFromUrl keeps classifying libsql:// / *.turso.* as turso (not ''), so those URLs hit the same loud failure instead of the SQLite fall-through.
  • No dev.ts / start.ts changes: turso is a real driver in the cloud distribution (which reuses these commands and documents OS_DATABASE_DRIVER=turso), so the honest fix is a clear error — not un-advertising it.

Verification

  • End-to-end (real os serve on the host-config path): OS_DATABASE_DRIVER=turso and OS_DATABASE_URL=libsql://my-db.turso.io both exit 1 with the fatal message; control OS_DATABASE_DRIVER=memory still boots.
  • ✅ Unit tests (storage-driver.test.ts) prove the branch goes red without it (dev→SqlDriver, prod→null) and assert the message is actionable. 18/18 in-file; 41/41 across serve/dev/storage suites.
  • tsc -p tsconfig.build.json + eslint clean.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Jul 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jul 19, 2026 4:54pm

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling size/m labels Jul 19, 2026
@github-actions

github-actions Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/cli.

17 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/ai/skills-reference.mdx (via packages/cli)
  • content/docs/api/client-sdk.mdx (via @objectstack/cli)
  • content/docs/api/data-flow.mdx (via @objectstack/cli)
  • content/docs/api/environment-routing.mdx (via @objectstack/cli)
  • content/docs/api/error-catalog.mdx (via @objectstack/cli)
  • content/docs/automation/hook-bodies.mdx (via packages/cli)
  • content/docs/deployment/backup-restore.mdx (via @objectstack/cli)
  • content/docs/deployment/self-hosting.mdx (via @objectstack/cli)
  • content/docs/getting-started/cli.mdx (via @objectstack/cli)
  • content/docs/getting-started/your-first-project.mdx (via @objectstack/cli)
  • content/docs/kernel/runtime-services/data-service.mdx (via packages/cli)
  • content/docs/kernel/runtime-services/index.mdx (via packages/cli)
  • content/docs/permissions/authentication.mdx (via @objectstack/cli)
  • content/docs/plugins/packages.mdx (via @objectstack/cli)
  • content/docs/protocol/kernel/plugin-spec.mdx (via @objectstack/cli)
  • content/docs/protocol/kernel/realtime-protocol.mdx (via @objectstack/cli)
  • content/docs/releases/implementation-status.mdx (via @objectstack/cli)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@xuyushun441-sys
xuyushun441-sys force-pushed the fix/cli-memory-driver-dispatch branch from e157e0c to d8cfa0b Compare July 19, 2026 16:10
@xuyushun441-sys
xuyushun441-sys force-pushed the fix/cli-turso-loud-error branch from 06550d7 to 728757e Compare July 19, 2026 16:11
Base automatically changed from fix/cli-memory-driver-dispatch to main July 19, 2026 16:19
…CLI (#3276 follow-up)

Same "declared ≠ enforced" bug class as the `memory` fix (#3276): `os dev` /
`os start` / `os serve` advertise a `turso` driver (`--database-driver turso`,
`OS_DATABASE_DRIVER=turso`, `libsql://` URLs), but the dispatch had no `turso`
branch — so selecting it silently fell through to the SQLite default and ignored
the requested remote libSQL connection.

turso/libSQL is a cloud/EE driver (`@objectstack/driver-turso`, an extension of
SqlDriver over `@libsql/client`), composed by the cloud runtime's own kernel
factory; the open-core standalone stack deliberately stopped consuming it and its
config schema lives in the cloud package to keep it out of `@objectstack/spec`.

Rather than pull the EE driver into open-core:
- `createStorageDriver` throws a typed `UnsupportedDriverError` for `turso` /
  `libsql`, with an actionable message (names @objectstack/driver-turso + the
  open-core alternatives).
- `serve.ts` re-throws it from the driver block's catch so run()'s fatal handler
  prints the message and exits 1 (dev AND prod) — never a silent SQLite boot.
- `inferDriverTypeFromUrl` keeps classifying `libsql://` / `*.turso.*` as `turso`
  (not '') so those URLs hit the same loud failure instead of the SQLite default.

Verified end-to-end: `OS_DATABASE_DRIVER=turso` and `OS_DATABASE_URL=libsql://...`
both exit 1 with the fatal message; `OS_DATABASE_DRIVER=memory` still boots. Unit
tests prove the branch goes red (dev→SqlDriver, prod→null) without it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@xuyushun441-sys
xuyushun441-sys force-pushed the fix/cli-turso-loud-error branch from 728757e to 977c2fe Compare July 19, 2026 16:21
@os-zhuang
os-zhuang merged commit 216c2db into main Jul 19, 2026
15 of 16 checks passed
@os-zhuang
os-zhuang deleted the fix/cli-turso-loud-error branch July 19, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant