fix(ida): report an idb_open rejection with its upstream reason

The database supervisor returns any open failure as { error } instead of
an MCP tool error. The client recognized that reply for cleanup, then
parsed it as a successful open and reported unreadable_output with
"malformed or unsupported producer data", dropping the supervisor's
reason. Raise the same IdaToolRejection that MCP tool errors produce,
with the redacted upstream reason.

Refs #13286

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
This commit is contained in:
gensokyo-devandgensokyo-dev authored and Ysopwnable committed 2026-11-22 13:38:30 +08:00
1 parent 4b86932527
commit 0cf7483322
2 files changed
+31 -3

No files matched your search

+19
View File
@@ -2241,3 +2241,22 @@ describe("headless IDA literal string predicate pushdown", () => {
}
});
});
describe("headless IDA open rejection", () => {
it("reports an idb_open rejection with its upstream reason", async () => {
const { producer, client } = await fixture("headless");
producer.overrideCall = (name) =>
name === "idb_open"
? { error: "Input was rejected before creating a session" }
: undefined;
const result = await client.execute("health", {});
expect(result.ok).toBe(false);
if (result.ok) return;
expect(result.error.message).toContain(
"Input was rejected before creating a session",
);
expect(result.error.message).not.toContain("malformed or unsupported");
expect((await client.close()).ok).toBe(true);
});
});
+12 -3
View File
@@ -800,10 +800,19 @@ export class IdaSessionClient implements AnalysisClient {
init_hexrays: true,
preferred_session_id: workspace.sessionId,
});
this.#openOutcome = rejectedOpenDatabaseSchema.safeParse(raw).success
? "no_worker"
: "reply_received";
const rejected = rejectedOpenDatabaseSchema.safeParse(raw);
this.#openOutcome = rejected.success ? "no_worker" : "reply_received";
this.#lifecycle.push(raw);
// The supervisor reports any open failure as `{ error }` rather than an
// MCP tool error; keep its reason instead of reading it as malformed data.
if (rejected.success) {
const diagnostic = createIdaDiagnosticRedactor(this.config);
const reason = diagnostic.blocks([rejected.data.error]);
throw new IdaToolRejection(
diagnostic.message("IDA MCP tool failed: ", reason),
{ diagnostics: { reason } },
);
}
const opened = openDatabaseSchema.parse(raw);
if (!sameIdaHostPath(opened.session.input_path, workspace.inputPath))
throw new IdaIdentityRefusal(