Repository navigation
Commit 66d456d
fix(cli): the memory:// / mingo:// OS_DATABASE_URL refusal names the scheme, never the URL (#23840)
Fixes #23792
Clause-②: no
## What changes
`inferDriverTypeFromUrl` in `packages/cli/src/utils/storage-driver.ts`
refuses a `memory://` or `mingo://` `OS_DATABASE_URL` (the retired
in-memory engine). Its refusal was built from the whole URL,
`OS_DATABASE_URL "URL"`, and `os serve` prints that message as it exits
1. Both schemes accept anything after the `//`, so a `user:password@`
and an `?authToken=` were printed to the console.
The arm now names the scheme only, in the runtime host's words: `An
OS_DATABASE_URL with the "memory://" scheme selects the in-memory
(mingo) engine, ...`. The rest of the sentence (the SQLite replacements)
comes from the shared `retiredMemoryEngineMessage`, unchanged. The
`UnsupportedDriverError` it throws now carries the scheme as
`driverType`, not the URL, as the unrecognised-scheme arm below it
already does.
Landing: the `memory` / `mingo` arm only, as the claim's file surface
names it. No other arm, the `OS_DATABASE_DRIVER` / `--database-driver`
arm, `packages/runtime` and the scheme parsing are untouched.
## Why the words are mirrored, not imported
The runtime phrase is built inside `refuseRetiredMemoryEngine` in
`packages/runtime/src/standalone-stack.ts`, and it is module-local:
`@objectstack/runtime` exports `retiredMemoryEngineMessage` (the shared
tail, already used here) but not the subject. The dispatch rules out a
new export from `packages/runtime` on this card, so the CLI arm writes
the subject out. A parity row in `driver-vocabulary-parity.test.ts`
holds the two hosts' refusals equal for the same credentialed URL (the
CLI's is the runtime's minus its `[StandaloneStack]` tag), so the copy
cannot drift silently.
## Reproduction at the public door
Built CLI, run from `examples/app-todo`, the URL carrying placeholder
credentials only:
```
OS_MODE=off OS_DATABASE_URL='SCHEME://PLACEHOLDER-USER:PLACEHOLDER-SECRET@127.0.0.1:6399/0?authToken=PLACEHOLDER-TOKEN' node ../../packages/cli/bin/run.js serve -p PORT
```
| | `memory://` | `mingo://` |
|:--|:--|:--|
| base `1ecb08a1cc` | exit 1; `PLACEHOLDER-USER` / `-SECRET` / `-TOKEN`
printed 1 / 1 / 1 time | exit 1; 1 / 1 / 1 |
| this branch (CLI built from `3ddd364ad`) | exit 1; 0 / 0 / 0, and
`127.0.0.1:6399` 0 | exit 1; 0 / 0 / 0, and `127.0.0.1:6399` 0 |
- Before: `✗ OS_DATABASE_URL
"memory://PLACEHOLDER-USER:PLACEHOLDER-SECRET@127.0.0.1:6399/0?authToken=PLACEHOLDER-TOKEN"
selects the in-memory (mingo) engine, ...`
- After: `✗ An OS_DATABASE_URL with the "memory://" scheme selects the
in-memory (mingo) engine, ...` (and `"mingo://"` for the other scheme).
## Pins
`packages/cli/src/utils/storage-driver.test.ts`:
- **The placeholder pin.** A `memory://` and a `mingo://` URL carrying a
placeholder user, password and token: the refusal is an
`UnsupportedDriverError` with `recognized: false` and `driverType` equal
to the scheme; its message names the scheme, `--fresh` and `:memory:`;
neither the message nor `driverType` contains any of the three
placeholders (nor the host).
- **CONTROL.** The same credentialed tail under `postgres://`,
`postgresql://`, `pg://`, `mysql://`, `mysql2://`, `mongodb://`,
`mongodb+srv://`, `libsql://` and `wasm-sqlite://` classifies as before.
The existing "maps each recognized URL scheme" and unrecognised-scheme
rows are unchanged and green.
- The existing memory-scheme row asserted the whole URL appeared in the
message (`memory://ignored-host`, `MINGO://x`). It now asserts the
scheme (`"memory://"`, `"MINGO://"`) and `driverType`.
`packages/cli/src/utils/driver-vocabulary-parity.test.ts`: for a
credentialed `memory://` and `mingo://` URL, both hosts refuse, name the
scheme, print none of the placeholders, and the CLI's message equals the
runtime's minus `[StandaloneStack] `.
## Tests (local)
- `pnpm --filter @objectstack/cli exec vitest run --project unit
--maxWorkers=2` on `a1a28595e`: `Test Files 297 passed (297)`, `Tests
4447 passed (4447)`, lock `VERDICT command-exit 0`. It ran longer than
one foreground call on this shared box (13m53s under the lock), so it
was started detached under the lock while the derived gates ran in the
foreground; its result was read from the lock's `VERDICT` line after it
exited.
- The two edited files alone, `--project unit` (both are unit-tier):
`Test Files 2 passed (2)`, `Tests 162 passed (162)`.
- `pnpm --filter @objectstack/cli typecheck` on `a1a28595e`: exit 0;
`check:test-typecheck: OK` (the test layer compiles under
`tsconfig.test.json`).
- `integration` tier: declared to CI. The diff touches no
integration-tier file and no spawn entry.
## Ablation (one-time, nothing kept)
The tests import `./storage-driver.js` relatively, so they read the
source and no rebuild is involved. Each leg through `node
scripts/ablation-replace.mjs` (anchor hit 1 to 0, blob changed, then
restored to the HEAD blob `74287da383` with `git diff HEAD` empty):
1. Subject back to the old `OS_DATABASE_URL "${u}"`: 6 failed / 156
passed. Red: the two placeholder pins, the two parity rows, and the
`memory://ignored-host` / `MINGO://x` scheme rows, each on the "names
the scheme" assertion.
2. Scheme kept but the URL appended (`... "${retiredScheme}" scheme
(${u})`), so the placeholder assertions are the first to fail: 4 failed
/ 158 passed, all four on `not to contain 'PLACEHOLDER-USER'` (both
placeholder pins, both parity rows).
3. `driverType` back to the URL (`u`): 4 failed / 158 passed, on
`expected 'memory://PLACEHOLDER-USER:...' to be 'memory://'` and the two
scheme rows.
## Gates
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` on `a1a28595e` (merge base `43567a8fc`, 4
paths, 121 changed lines): 64 commands. Reconciled with `--ran`: `64
derived famil(ies) accounted for — 62 run, 2 NOT-MEASURED`.
- 62 exit 0.
- NOT MEASURED: `check:dual-build-cjs-loads` and `check:i18n-coverage`,
both exit 3 `PREREQUISITE NOT MET` (packages outside the CLI's build
closure have no `dist/` here). CI's `Lint & Repo Gates` runs both.
- `pnpm exec eslint --no-inline-config` over the three edited `.ts`
files: exit 0. The repo-wide lint is CI's `Lint & Repo Gates`.
- Control-byte self-scan of the four changed files: no match.
## Acceptance notes
- **Other CLI sites printing the database URL (measured, none).** A grep
of `packages/cli/src` (tests excluded) for the URL interpolated into a
`throw`, `console.*`, `logger.*` or `print*` line finds only this arm.
The startup banner, the migration line and `os start`'s `Database` line
already pass the URL through `redactConnectionUrl`.
- **Not touched:** the `OS_DATABASE_DRIVER` / `--database-driver` arm
(it prints a driver name, not a URL), `packages/runtime`, and the scheme
parsing; #23794 and #23796 remain open.
- **Doc drift, noted and not filed (carrier: none).** The TSDoc of
`retiredMemoryEngineMessage` in
`packages/runtime/src/resolve-project-database.ts` still gives `The
database URL "memory://"` as an example subject. The runtime host now
says `A database URL with the "memory://" scheme`. Comment only; no
behaviour reads it.
- Placeholder credentials only, here and in the pins.
The Tests section's account of the detached unit run was corrected by
the `domain:cli` seat 2 PM (session `session_018t6a5rvqPRvEDMCVVW9kYT`)
at review, from the dev report's deviation 1.
Co-authored-by: Claude <noreply@anthropic.com>1 parent ee0e115 commit 66d456d
4 files changed
Lines changed: 113 additions & 8 deletions
File tree
- .changeset
- packages/cli/src/utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
260 | 282 | | |
261 | 283 | | |
262 | 284 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
68 | 73 | | |
69 | 74 | | |
70 | 75 | | |
| |||
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
78 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
79 | 86 | | |
80 | 87 | | |
81 | 88 | | |
82 | 89 | | |
83 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
84 | 139 | | |
85 | 140 | | |
86 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
331 | | - | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
332 | 342 | | |
333 | | - | |
334 | | - | |
| 343 | + | |
| 344 | + | |
335 | 345 | | |
336 | 346 | | |
337 | 347 | | |
| |||
0 commit comments