[GH-ISSUE #5520] [Bug] SQLite malformed-database errors omit the selected file path #3356

Closed
opened 2026-10-31 00:39:29 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @coygeek on GitHub (Oct 20, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/5520

Before submitting

  • I searched the open and closed issues for a related report.
  • I removed credentials, tokens, private paths, and sensitive target data.

Area

CLI

Observed behavior

node scripts/rea.mjs inspect-sqlite-database <selected absolute path> --json correctly rejects a readable non-SQLite file, but its JSON error does not identify the selected file. An independent verifier inspected two distinct malformed files and received identical complete error documents. Both exited 1 with empty stderr.

Reproduction

Run from the source checkout identified below, with dependencies and the built runtime prepared. The independent verifier executed the following reproduction and its directory and valid-database controls.

With TMPDIR set to a writable disposable workspace, create isolated local inputs and runtime directories:

SCRATCH=$(mktemp -d "${TMPDIR%/}/sqlite-path.XXXXXX")
export HOME="$SCRATCH/home"
export XDG_CONFIG_HOME="$SCRATCH/config"
export XDG_DATA_HOME="$SCRATCH/data"
export XDG_CACHE_HOME="$SCRATCH/cache"
export XDG_STATE_HOME="$SCRATCH/state"
export TMPDIR="$SCRATCH/temp"
export REA_LOG_LEVEL=silent
mkdir -p "$HOME" "$XDG_CONFIG_HOME" "$XDG_DATA_HOME" "$XDG_CACHE_HOME" "$XDG_STATE_HOME" "$TMPDIR"
printf 'this is not a sqlite database' > "$SCRATCH/garbage-a.db"
printf 'this is not a sqlite database' > "$SCRATCH/garbage-b.db"
mkdir "$SCRATCH/directory.db"
node -e 'const {DatabaseSync}=require("node:sqlite");const db=new DatabaseSync(process.argv[1]);db.exec("create table t(a)");db.close()' "$SCRATCH/valid.db"

Inspect the two malformed files, then the directory and valid-database controls. Each invocation selects exactly one input. This loop prints each exit status and saves the complete output:

for file in garbage-a.db garbage-b.db directory.db valid.db; do
  if node scripts/rea.mjs inspect-sqlite-database "$SCRATCH/$file" --json > "$SCRATCH/$file.json" 2> "$SCRATCH/$file.stderr"; then
    printf '%s exit=0\n' "$file"
  else
    printf '%s exit=%s\n' "$file" "$?"
  fi
  cat "$SCRATCH/$file.json"
done

Compare the malformed errors and check whether they contain the selected path:

node -e 'const fs=require("node:fs");const root=process.argv[1];const a=JSON.parse(fs.readFileSync(root+"/garbage-a.db.json","utf8"));const b=JSON.parse(fs.readFileSync(root+"/garbage-b.db.json","utf8"));console.log({equal:JSON.stringify(a)===JSON.stringify(b),aHasSelectedPath:JSON.stringify(a).includes(root+"/garbage-a.db"),bHasSelectedPath:JSON.stringify(b).includes(root+"/garbage-b.db")});' "$SCRATCH"

Expected behavior

Each malformed-file error should include that invocation's selected database path and a meaningful format reason. docs/sqlite-databases.md:136-139, under "Source files and failures", explicitly includes malformed databases in its promise to report the selected path and meaningful reason.

Impact and scope

P3 diagnostic-context defect. Both malformed selections reproduced it; the refusal, exit status and format reason remain correct. Each request selects one database, so retaining the selected path or full command alongside its error is a practical workaround. No incorrect successful inspection or source-data loss was observed. MCP and other platforms were not executed for this report.

REA version

6.7.0; source commit 074768901f3cdc8205b61773fb1faf6f6c7b3ca8, prepared built CLI.

Runtime and platform

Node.js v26.12.0; macOS, darwin. NOT_ENOUGH_INFO: the verifier did not record the architecture or OS release. No external analysis provider was involved.

Target and artifact context

Two locally generated readable regular files containing this is not a sqlite database. Controls were a directory and a real SQLite database containing table t. CLI configuration and runtime directories were isolated as shown above.

Interface

CLI

Earliest failure stage

Transport or result projection

Relevant output or evidence

Both malformed-file calls returned code: "invalid_request", category: "invalid_input", and the message Analysis input is invalid. Check the arguments and try again. Each contained this issue:

{"path":["path"],"reason":"invalid_format","message":"file is not a database"}

The comparison printed equal: true, aHasSelectedPath: false, and bHasSelectedPath: false. The array ["path"] identifies the argument key, not the selected file value; neither complete error document included its selected path.

The directory control exited 1 and identified its selected absolute directory path in Expected a regular file without a symlink: <selected absolute directory path>. The valid-database control exited 0 and included table t in its schema inventory. Both controls had empty stderr.

Typed outcome or recovery expected

Preserve the malformed-input refusal and meaningful format reason while including the caller-selected database path. Proposed restoration check: repeat both malformed selections and require each error to identify its own selected path; keep the directory refusal and valid-database success controls.

Analysis or suspected cause

Source-derived reasoning at the tested revision: src/sqlite/SqliteDatabaseWorker.ts:31-44 serializes the SQLite exception message. src/sqlite/SqliteDatabaseWorkerExecution.ts:102-108 transfers that message into an input issue without the selected file value. src/sqlite/SqliteDatabaseFailures.ts:55 preserves the existing AnalysisError, so the outer mapper does not add the selected path. The acceptance case at tests/acceptance/sqliteDatabaseCli.test.ts:674-694 checks rejection without requiring this path.

Additional context

Prepared with AI assistance and independently reproduced through the CLI. Upstream main was fetched at c374c2fe7290b914d73d9e27af38b498753ec593. The later SQLite cleanup change 100671427105791a5c5913a918b63a394f6bc83e does not change the malformed-error projection or the documentation promise. Current-main applicability is source-inspected, not a separate current-main runtime reproduction.

Related reports have different triggers and closure checks: #2614 concerns missing-path classification, #4188 concerns path-resolution failures, #2613 concerns the argument key for unknown column selections, and #5456 concerns recovery advice for reply-budget refusals. NOT_ENOUGH_INFO: no last-known-good version was established.

Originally created by @coygeek on GitHub (Oct 20, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/5520 ### Before submitting - [x] I searched the open and closed issues for a related report. - [x] I removed credentials, tokens, private paths, and sensitive target data. ### Area CLI ### Observed behavior `node scripts/rea.mjs inspect-sqlite-database <selected absolute path> --json` correctly rejects a readable non-SQLite file, but its JSON error does not identify the selected file. An independent verifier inspected two distinct malformed files and received identical complete error documents. Both exited 1 with empty stderr. ### Reproduction Run from the source checkout identified below, with dependencies and the built runtime prepared. The independent verifier executed the following reproduction and its directory and valid-database controls. With `TMPDIR` set to a writable disposable workspace, create isolated local inputs and runtime directories: ```sh SCRATCH=$(mktemp -d "${TMPDIR%/}/sqlite-path.XXXXXX") export HOME="$SCRATCH/home" export XDG_CONFIG_HOME="$SCRATCH/config" export XDG_DATA_HOME="$SCRATCH/data" export XDG_CACHE_HOME="$SCRATCH/cache" export XDG_STATE_HOME="$SCRATCH/state" export TMPDIR="$SCRATCH/temp" export REA_LOG_LEVEL=silent mkdir -p "$HOME" "$XDG_CONFIG_HOME" "$XDG_DATA_HOME" "$XDG_CACHE_HOME" "$XDG_STATE_HOME" "$TMPDIR" printf 'this is not a sqlite database' > "$SCRATCH/garbage-a.db" printf 'this is not a sqlite database' > "$SCRATCH/garbage-b.db" mkdir "$SCRATCH/directory.db" node -e 'const {DatabaseSync}=require("node:sqlite");const db=new DatabaseSync(process.argv[1]);db.exec("create table t(a)");db.close()' "$SCRATCH/valid.db" ``` Inspect the two malformed files, then the directory and valid-database controls. Each invocation selects exactly one input. This loop prints each exit status and saves the complete output: ```sh for file in garbage-a.db garbage-b.db directory.db valid.db; do if node scripts/rea.mjs inspect-sqlite-database "$SCRATCH/$file" --json > "$SCRATCH/$file.json" 2> "$SCRATCH/$file.stderr"; then printf '%s exit=0\n' "$file" else printf '%s exit=%s\n' "$file" "$?" fi cat "$SCRATCH/$file.json" done ``` Compare the malformed errors and check whether they contain the selected path: ```sh node -e 'const fs=require("node:fs");const root=process.argv[1];const a=JSON.parse(fs.readFileSync(root+"/garbage-a.db.json","utf8"));const b=JSON.parse(fs.readFileSync(root+"/garbage-b.db.json","utf8"));console.log({equal:JSON.stringify(a)===JSON.stringify(b),aHasSelectedPath:JSON.stringify(a).includes(root+"/garbage-a.db"),bHasSelectedPath:JSON.stringify(b).includes(root+"/garbage-b.db")});' "$SCRATCH" ``` ### Expected behavior Each malformed-file error should include that invocation's selected database path and a meaningful format reason. `docs/sqlite-databases.md:136-139`, under "Source files and failures", explicitly includes malformed databases in its promise to report the selected path and meaningful reason. ### Impact and scope P3 diagnostic-context defect. Both malformed selections reproduced it; the refusal, exit status and format reason remain correct. Each request selects one database, so retaining the selected path or full command alongside its error is a practical workaround. No incorrect successful inspection or source-data loss was observed. MCP and other platforms were not executed for this report. ### REA version 6.7.0; source commit `074768901f3cdc8205b61773fb1faf6f6c7b3ca8`, prepared built CLI. ### Runtime and platform Node.js v26.12.0; macOS, `darwin`. NOT_ENOUGH_INFO: the verifier did not record the architecture or OS release. No external analysis provider was involved. ### Target and artifact context Two locally generated readable regular files containing `this is not a sqlite database`. Controls were a directory and a real SQLite database containing table `t`. CLI configuration and runtime directories were isolated as shown above. ### Interface CLI ### Earliest failure stage Transport or result projection ### Relevant output or evidence Both malformed-file calls returned `code: "invalid_request"`, `category: "invalid_input"`, and the message `Analysis input is invalid. Check the arguments and try again.` Each contained this issue: ```json {"path":["path"],"reason":"invalid_format","message":"file is not a database"} ``` The comparison printed `equal: true`, `aHasSelectedPath: false`, and `bHasSelectedPath: false`. The array `["path"]` identifies the argument key, not the selected file value; neither complete error document included its selected path. The directory control exited 1 and identified its selected absolute directory path in `Expected a regular file without a symlink: <selected absolute directory path>`. The valid-database control exited 0 and included table `t` in its schema inventory. Both controls had empty stderr. ### Typed outcome or recovery expected Preserve the malformed-input refusal and meaningful format reason while including the caller-selected database path. Proposed restoration check: repeat both malformed selections and require each error to identify its own selected path; keep the directory refusal and valid-database success controls. ### Analysis or suspected cause Source-derived reasoning at the tested revision: `src/sqlite/SqliteDatabaseWorker.ts:31-44` serializes the SQLite exception message. `src/sqlite/SqliteDatabaseWorkerExecution.ts:102-108` transfers that message into an input issue without the selected file value. `src/sqlite/SqliteDatabaseFailures.ts:55` preserves the existing AnalysisError, so the outer mapper does not add the selected path. The acceptance case at `tests/acceptance/sqliteDatabaseCli.test.ts:674-694` checks rejection without requiring this path. ### Additional context Prepared with AI assistance and independently reproduced through the CLI. Upstream main was fetched at `c374c2fe7290b914d73d9e27af38b498753ec593`. The later SQLite cleanup change `100671427105791a5c5913a918b63a394f6bc83e` does not change the malformed-error projection or the documentation promise. Current-main applicability is source-inspected, not a separate current-main runtime reproduction. Related reports have different triggers and closure checks: #2614 concerns missing-path classification, #4188 concerns path-resolution failures, #2613 concerns the argument key for unknown column selections, and #5456 concerns recovery advice for reply-budget refusals. NOT_ENOUGH_INFO: no last-known-good version was established.
Author
Owner

@matbrgz commented on GitHub (Oct 20, 2026):

Cross-referencing with canonical issue #4184 and siblings #5284, #5286, and #5294. Addresses SQLite inspection error diagnosis and missing file path context on malformed targets. Cataloged under Cluster AS in consolidation tracker #4330.

<!-- gh-comment-id:6292620459 --> @matbrgz commented on GitHub (Oct 20, 2026): Cross-referencing with canonical issue #4184 and siblings #5284, #5286, and #5294. Addresses SQLite inspection error diagnosis and missing file path context on malformed targets. Cataloged under Cluster AS in consolidation tracker #4330.
Author
Owner

@CassieFox23 commented on GitHub (Oct 20, 2026):

TL;DR: This still happens on main on Linux. A text file given to inspect-sqlite-database is rejected, but the error never names the file. Two different bad files give the same output.

Checked on main b3aadaf47 (Node 24.18.0). Both runs exit 1 with invalid_request and "Analysis input is invalid. Check the arguments and try again." The only detail is file is not a database on the path field. The selected path appears nowhere in the output. The two files give byte-identical output. The error also says retryable: true.

Not run

  • The directory control. A control run on a valid database. MCP.

Thanks, coygeek, for the clear report.

Commands
printf 'this is not a sqlite database' > <case_dir>/garbage-a.db
printf 'this is not a sqlite database' > <case_dir>/garbage-b.db
node scripts/rea.mjs inspect-sqlite-database <case_dir>/garbage-a.db --json
node scripts/rea.mjs inspect-sqlite-database <case_dir>/garbage-b.db --json

Each exit 1, stderr 0 bytes. First output:

{"code":"invalid_request","category":"invalid_input","message":"Analysis input is invalid. Check the arguments and try again.","retryable":true,"remediation":{"action":"Read the declared input schema or CLI usage for inspect_sqlite_database; ... Do not repeat the unchanged call."},"recovery":{"kind":"inspect_input_contract","operation":"inspect_sqlite_database"},"details":{"operation":"inspect_sqlite_database","issues":[{"path":["path"],"reason":"invalid_format","message":"file is not a database"}],"captured_output":{"stdout":"","stderr":"","truncated":false}}}

Isolated HOME, XDG and TMPDIR; run once per file.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.11
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 24.18.0
  • Head: b3aadaf47

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

<!-- gh-comment-id:6298172607 --> @CassieFox23 commented on GitHub (Oct 20, 2026): **TL;DR:** This still happens on main on Linux. A text file given to `inspect-sqlite-database` is rejected, but the error never names the file. Two different bad files give the same output. Checked on main b3aadaf47 (Node 24.18.0). Both runs exit 1 with `invalid_request` and "Analysis input is invalid. Check the arguments and try again." The only detail is `file is not a database` on the `path` field. The selected path appears nowhere in the output. The two files give byte-identical output. The error also says `retryable: true`. ### Not run - The directory control. A control run on a valid database. MCP. Thanks, coygeek, for the clear report. <details> <summary>Commands</summary> ```sh printf 'this is not a sqlite database' > <case_dir>/garbage-a.db printf 'this is not a sqlite database' > <case_dir>/garbage-b.db node scripts/rea.mjs inspect-sqlite-database <case_dir>/garbage-a.db --json node scripts/rea.mjs inspect-sqlite-database <case_dir>/garbage-b.db --json ``` Each exit 1, stderr 0 bytes. First output: ```json {"code":"invalid_request","category":"invalid_input","message":"Analysis input is invalid. Check the arguments and try again.","retryable":true,"remediation":{"action":"Read the declared input schema or CLI usage for inspect_sqlite_database; ... Do not repeat the unchanged call."},"recovery":{"kind":"inspect_input_contract","operation":"inspect_sqlite_database"},"details":{"operation":"inspect_sqlite_database","issues":[{"path":["path"],"reason":"invalid_format","message":"file is not a database"}],"captured_output":{"stdout":"","stderr":"","truncated":false}}} ``` Isolated HOME, XDG and TMPDIR; run once per file. </details> <details> <summary>Test setup</summary> - Box: Nobara 44 (Fedora 44 base), Linux 7.2.11 - CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads - RAM: 32 GB DDR4-3600 - Node: 24.18.0 - Head: b3aadaf47 </details> 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#3356
No description provided.