fix(sqlite): refuse one-byte files instead of reporting an empty schema (#8727)

* fix(sqlite): refuse one-byte files instead of reporting an empty schema

* test(sqlite): assert refusal facts instead of the full error sentence

The one-byte and corrupt-input acceptance tests froze the sentence that
SqliteDatabaseWorkerExecution builds from fixed wording, SQLite's
diagnostic and the selected path. Share one helper that keeps the code,
issue path, reason and single-issue shape exact, and checks the
diagnostic and selected path separately, so rewording the sentence no
longer breaks either regression.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ali RazaandClaude Opus 5.5 authored and GitHub committed 2026-11-18 13:11:23 -05:00
1 parent 5fd6c0db71
commit f64433c93e
2 files changed
+44 -14

No files matched your search

+5
View File
@@ -1,3 +1,4 @@
import { statSync } from "node:fs";
import { DatabaseSync } from "node:sqlite";
import { z } from "zod";
import { Budget } from "../domain/budget.js";
@@ -1068,6 +1069,10 @@ export const inspectSqliteDatabaseSnapshot = (
snapshotPath: string,
input: InspectSqliteDatabaseInput,
): Inspection => {
// SQLite's Unix VFS reports a one-byte file as size zero, so the engine would
// open it as an empty database and never reach its own header check.
if (statSync(snapshotPath).size === 1)
throw new SqliteInspectionFailure("format", "file is not a database");
const db = new DatabaseSync(snapshotPath, {
readOnly: true,
allowExtension: false,