Reverse engineer anything with agents, from app behavior down to native binaries.
TypeScript agent-skillsai-agentsbinary-analysisclaude-codeclicodexcordisdecompilerdeveloper-toolsdshdsh-pluginghidrahopperllmmcpmodel-context-protocolreareverse-engineeringstatic-analysistouhou
fix(sqlite): name the selected path in malformed-database errors (#5564)
Kaoru0822c1e04bf8c03e
diff --git a/src/sqlite/SqliteDatabaseWorkerExecution.ts b/src/sqlite/SqliteDatabaseWorkerExecution.tsindex d3fea3392..ab4acc5b8 100644--- a/src/sqlite/SqliteDatabaseWorkerExecution.ts+++ b/src/sqlite/SqliteDatabaseWorkerExecution.ts@@ -70,6 +70,7 @@ const rejectedArgument = {const rejectedReply = (reply: z.output<typeof replySchema> & { ok: false },+ selectedPath: string,capturedOutput: AnalysisCapturedOutput,) => {if (reply.reason === "unavailable")@@ -103,11 +104,16 @@ const rejectedReply = (...fixedAllowanceOptions("The SQLite worker reply allowance", "report"),},);+ const argument = rejectedArgument[reply.reason];return new AnalysisInputError(operation, { capturedOutput }, [{- path: [rejectedArgument[reply.reason]],+ path: [argument],reason: "invalid_format",- message: reply.message,+ // The worker sees only the private snapshot, so name the caller's selection here.+ message:+ argument === "path"+ ? `Selected SQLite database is invalid (${reply.message}): ${selectedPath}`+ : reply.message,},]);};@@ -210,6 +216,6 @@ export const executeSqliteDatabaseWorker = async (request: {bindArtifactFileCleanup(cause, error);throw error;}- if (!reply.ok) throw rejectedReply(reply, capturedOutput);+ if (!reply.ok) throw rejectedReply(reply, request.input.path, capturedOutput);return reply.inspection;};diff --git a/tests/acceptance/sqliteDatabaseCli.test.ts b/tests/acceptance/sqliteDatabaseCli.test.tsindex d0ffb361c..de018b424 100644--- a/tests/acceptance/sqliteDatabaseCli.test.ts+++ b/tests/acceptance/sqliteDatabaseCli.test.ts@@ -678,17 +678,33 @@ cliTest.runIf(SQLITE_NATIVE_LIMITS_AVAILABLE)(async ({ cli }) => {const root = await createTestTempDirectory("rea-sqlite-errors-public-");const path = join(root, "invalid.db");- await writeFile(path, "not a SQLite database");const { call } = await connectLocalToolsMcp();- const corrupt = await cli.run({- arguments: ["inspect-sqlite-database", path, "--json"],- environment: { REA_LOG_LEVEL: "silent" },- });- expect(corrupt.exitCode).toBe(1);- expect(corrupt.json).toMatchObject({ code: "invalid_request" });- expect((await call("inspect_sqlite_database", { path })).isError).toBe(- true,- );+ // Distinct malformed selections each name their own selected path.+ for (const selected of [path, join(root, "other-invalid.db")]) {+ await writeFile(selected, "not a SQLite database");+ const expectedError = {+ code: "invalid_request",+ details: {+ issues: [+ {+ path: ["path"],+ reason: "invalid_format",+ message: `Selected SQLite database is invalid (file is not a database): ${selected}`,+ },+ ],+ },+ };+ const corrupt = await cli.run({+ arguments: ["inspect-sqlite-database", selected, "--json"],+ environment: { REA_LOG_LEVEL: "silent" },+ });+ expect(corrupt.exitCode).toBe(1);+ expect(corrupt.json).toMatchObject(expectedError);+ const response = await call("inspect_sqlite_database", {+ path: selected,+ });+ expect(parseMcpToolError(response).error).toMatchObject(expectedError);+ }const valid = join(root, "valid.db");const database = new DatabaseSync(valid);try {