fix(cli): reject invalid JavaScript application paths (#9789)

Validate analyze-javascript-application paths with the shared localPathStringSchema before anchoring or provider execution. Empty paths now return CLI field errors; NUL bytes are rejected at the same boundary. Preserve selected-path Evidence for valid inputs and update the CLI regressions. Closes #9747.
This commit is contained in:
Beqa authored and GitHub committed 2026-11-10 13:50:42 +00:00
1 parent a4da4e7230
commit b2f3dc81fa
3 files changed
+49 -17

No files matched your search

@@ -178,18 +178,9 @@ cliTest(
);
// Anchoring must not turn an empty selection into the working directory.
cliTest.for([
{
command: "analyze-javascript-application",
rejection: {
code: "invalid_request",
details: { issues: [expect.objectContaining({ path: ["input_path"] })] },
},
},
{ command: "analyze", rejection: { code: "VALIDATION_ERROR" } },
])(
"$command rejects an empty path instead of analyzing the working directory",
async ({ command, rejection }, { cli }) => {
cliTest.for(["analyze-javascript-application", "analyze"])(
"%s rejects an empty path instead of analyzing the working directory",
async (command, { cli }) => {
const root = await createTestTempDirectory("rea-js-empty-path-");
await writeFile(join(root, "main.js"), "export const value = 7;\n");
const response = await cli.run({
@@ -198,6 +189,11 @@ cliTest.for([
environment: { REA_LOG_LEVEL: "silent" },
});
expect(response.exitCode, response.stderr).toBe(1);
expect(response.json).toMatchObject(rejection);
expect(response.json).toMatchObject({
code: "VALIDATION_ERROR",
fieldErrors: [
expect.objectContaining({ path: "path", code: "too_small" }),
],
});
},
);