fix(sqlite): classify a missing database path as an invalid value (#2775)
* fix(sqlite): classify a missing database path as an invalid value The snapshot reported an absent selected database as an artifact path failure, which the adapter projects as invalid_format alongside malformed paths and content. The snapshot owns the absence observation, so it now returns an invalid_value input issue on path directly, matching the adapter's existing ENOENT/ENOTDIR classification. Fixes #2614 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(sqlite): classify a missing database path as an invalid value The snapshot reported an absent selected database as an artifact path failure, which the adapter projects as invalid_format alongside malformed paths and content. The snapshot owns the absence observation, so it now returns an invalid_value input issue on path directly, matching the adapter's existing ENOENT/ENOTDIR classification. Fixes #2614 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
morluto
parent
c8e85b962a
commit
4c79127fcb
@@ -3,6 +3,7 @@ import { constants, type BigIntStats } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";
|
||||
import type { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
|
||||
import { AnalysisInputError } from "../domain/analysisErrorCore.js";
|
||||
import { OwnedFileHandle } from "../filesystem/OwnedFileHandle.js";
|
||||
import {
|
||||
readStableArtifact,
|
||||
@@ -166,6 +167,16 @@ const verifyInactiveJournal = async (
|
||||
}
|
||||
};
|
||||
|
||||
// Absence is a caller value to correct, not malformed path or content.
|
||||
const missingDatabase = (path: string): AnalysisInputError =>
|
||||
new AnalysisInputError("inspect_sqlite_database", undefined, [
|
||||
{
|
||||
path: ["path"],
|
||||
reason: "invalid_value",
|
||||
message: `Selected SQLite database does not exist: ${path}`,
|
||||
},
|
||||
]);
|
||||
|
||||
/** Freeze a stable offline file set without ever opening the source through SQLite. */
|
||||
export const captureSqliteDatabaseSnapshot = async (
|
||||
path: string,
|
||||
@@ -183,11 +194,7 @@ export const captureSqliteDatabaseSnapshot = async (
|
||||
const wal = before[1];
|
||||
if (database === undefined || wal === undefined || before[2] === undefined)
|
||||
throw new Error("Incomplete database file-set observation");
|
||||
if (database === null)
|
||||
throw new ArtifactReaderFailure(
|
||||
"path",
|
||||
`Selected SQLite database does not exist: ${path}`,
|
||||
);
|
||||
if (database === null) throw missingDatabase(path);
|
||||
if (before[2] !== null)
|
||||
await verifyInactiveJournal(
|
||||
`${path}-journal`,
|
||||
|
||||
@@ -357,6 +357,30 @@ it("does not execute views when selecting rows", async () => {
|
||||
});
|
||||
});
|
||||
|
||||
nativeTest.each(["absent.db", "absent-parent/absent.db"])(
|
||||
"classifies a missing %s as an invalid value",
|
||||
async (name) => {
|
||||
const workspace = await createTestWorkspace("rea-sqlite-missing-");
|
||||
onTestFinished(() => removeTestWorkspace(workspace.root));
|
||||
const path = workspace.path(name);
|
||||
const provider = createProvider();
|
||||
onTestFinished(() => provider.close());
|
||||
const result = await provider.inspect({ path });
|
||||
if (result.ok) throw new Error("Expected a missing database rejection");
|
||||
expect(projectAnalysisError(result.error)).toMatchObject({
|
||||
details: {
|
||||
issues: [
|
||||
{
|
||||
path: ["path"],
|
||||
reason: "invalid_value",
|
||||
message: `Selected SQLite database does not exist: ${path}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it("attributes table and column selection failures to their own arguments", async () => {
|
||||
const { database } = await createFixture();
|
||||
const provider = createProvider();
|
||||
|
||||
Reference in New Issue
Block a user