* fix(sqlite): attribute generated-column evaluation failures to the selection A selected virtual generated column whose expression needs a function the read-only connection lacks (or raises an SQL error for a sampled row) was classified by the worker's catch-all as a malformed database and projected as an invalid_format issue on `path`. Row reads now attribute SQLITE_ERROR from selected cells by probing each selected virtual generated column over the sampled rows, and report a typed capability_unavailable refusal naming the table, each failing column with SQLite's message, and the remaining columns to select. Other causes, including corruption, TOOBIG and NOMEM, keep their classification. Fixes #5719 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(sqlite): recommend only probed-readable columns after evaluation failures Record every per-column probe failure with its own reason, discover stored columns outside an inventory-scope selection without decoding unrelated malformed names, and present recovery as the structured columns selection instead of shell-quoted command text built from database-supplied names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
/** Bound frozen input, retained JSON and worker allocation before parsing untrusted files. */
|
|
export const SQLITE_DATABASE_LIMITS = {
|
|
concurrentInspections: 2,
|
|
inputBytes: 256 * 1024 * 1024,
|
|
outputBytes: 16 * 1024 * 1024,
|
|
diagnosticBytes: 1024 * 1024,
|
|
} as const;
|
|
/** Internal rejection retains the failed boundary without returning partial success. */
|
|
export class SqliteInspectionFailure extends Error {
|
|
constructor(
|
|
readonly reason:
|
|
| "format"
|
|
| "selection"
|
|
| "column-selection"
|
|
| "column-evaluation"
|
|
| "unsupported"
|
|
| "unavailable"
|
|
| "output-limit"
|
|
| "memory",
|
|
message: string,
|
|
) {
|
|
super(message);
|
|
}
|
|
}
|
|
/** Selected generated cells the private connection cannot compute; the database stays readable. */
|
|
export class SqliteColumnEvaluationFailure extends SqliteInspectionFailure {
|
|
constructor(
|
|
message: string,
|
|
/** Selected or stored columns that remain readable without the failed expressions. */
|
|
readonly readableColumns: readonly string[],
|
|
) {
|
|
super("column-evaluation", message);
|
|
}
|
|
}
|
|
/** SQLite's primary result code for a native node:sqlite failure, if it carries one. */
|
|
export const sqlitePrimaryResultCode = (cause: unknown): number | undefined =>
|
|
cause instanceof Error &&
|
|
"errcode" in cause &&
|
|
typeof cause.errcode === "number"
|
|
? cause.errcode & 0xff
|
|
: undefined;
|