fix(frida): name the argument each Frida input error rejects (#2217)

Frida session lookups, script lookups, unreadable script files and the
instrument-with-frida PID and script checks returned invalid_request with
no issues, while the remediation told callers to correct the listed
arguments. Attach the session_id, script_id, path, target or script issue
with the reason so CLI and MCP callers can see what to fix.

Fixes #2213

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kaoru0822
2026-10-12 23:00:59 +08:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 109769319a
commit 86de439ba4
6 changed files with 146 additions and 9 deletions
+40
View File
@@ -234,3 +234,43 @@ it("preserves observed devices when CLI provider cleanup fails", async () => {
details: { diagnostics: { partial_observation: { devices } } },
});
});
it.each([
[
["attach", "abc", "--script", "send(1)"],
"target",
"attach mode needs a positive integer process ID.",
],
[
["attach", "71"],
"script",
"Provide exactly one of --script or --script-file.",
],
])(
"names the rejected instrument-with-frida argument for %j",
async (argv, path, message) => {
let starts = 0;
const provider = {
async startSession() {
starts += 1;
throw new Error("Frida must not start for invalid input");
},
} as unknown as FridaInstrumentationPort;
const cli = createCli({}, undefined, provider);
let stdout = "";
await cli.serve(["instrument-with-frida", ...argv, "--json"], {
env: {},
exit: () => undefined,
stdout: (text) => {
stdout += text;
},
});
expect(JSON.parse(stdout)).toMatchObject({
code: "invalid_request",
details: {
issues: [{ path: [path], reason: "invalid_value", message }],
},
});
expect(starts).toBe(0);
},
);