fix(storage): an unknown nested storage config can never silently land on the shared default root
The factory loudly rejects every REMOVED pre-8.0 path key, but an unknown
nested `config` object (e.g. `storage: { config: { baseDir } }` — a shape
that was never supported) fell through SILENTLY to the zero-config default
directory. Every instance constructed with such a shape wrote to ONE shared
on-disk root while its caller believed each had its own — found live when
two integration tests' brains shared a store across an entire
single-process CI run and a health probe refused on the foreign edges it
sampled. A nested `config` carrying any path-shaped key now throws the same
loud migration error, naming the canonical `path` rename. The two tests are
repaired to the supported shape (and now actually test isolated stores, for
the first time since 8.0).
This commit is contained in:
parent
8cced871a0
commit
ddd5e71928
3 changed files with 17 additions and 14 deletions
|
|
@ -154,6 +154,21 @@ export function resolveFilesystemRoot(
|
|||
) {
|
||||
throwRemovedStorageKey('fileSystemStorage.path')
|
||||
}
|
||||
// A nested `config` object carrying a path-shaped key is the same hazard in
|
||||
// a shape nobody ever supported: it used to fall through SILENTLY to the
|
||||
// shared default root — every instance writing one directory while its
|
||||
// caller believed each had its own. (Found live: an integration test's
|
||||
// brains shared one store across a whole single-process run and a health
|
||||
// probe refused on the foreign edges it sampled.) Loud, with the rename.
|
||||
const nested = (config as Record<string, unknown>).config
|
||||
if (nested && typeof nested === 'object') {
|
||||
const pathish = ['path', 'baseDir', 'rootDirectory', 'rootDir', 'dir', 'directory']
|
||||
const hit = pathish.find(
|
||||
(k) => typeof (nested as Record<string, unknown>)[k] === 'string' &&
|
||||
((nested as Record<string, unknown>)[k] as string).length > 0
|
||||
)
|
||||
if (hit) throwRemovedStorageKey(`config.${hit}`)
|
||||
}
|
||||
|
||||
// 3. Zero-config default. A `type: 'filesystem'` with no path lands here
|
||||
// intentionally ("persist, default location").
|
||||
|
|
|
|||
Reference in a new issue