Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sdk/typescript/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1216,13 +1216,13 @@ export async function main(
args: readonly string[],
select: (value: JsonObject) => JsonObject | Promise<JsonObject> = (value) =>
value,
): Promise<JsonObject | undefined> => {
): Promise<JsonObject> => {
try {
return await select(await dependencies.runWorkbench(args));
} catch (error) {
errorOutput.write(`codex-security: ${errorMessage(error)}\n`);
exitCode = 2;
return undefined;
throw error;
}
};
const latestScans = async (
Expand Down Expand Up @@ -1613,7 +1613,7 @@ export async function main(
} catch (error) {
errorOutput.write(`codex-security: ${errorMessage(error)}\n`);
exitCode = 2;
return undefined;
throw error;
}
},
})
Expand Down
26 changes: 26 additions & 0 deletions sdk/typescript/tests-ts/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,32 @@ describe("CLI", () => {
);
});

test("does not emit an ok: true envelope for a failed structured history command", async () => {
for (const argv of [
["scans", "show", "--json"],
["scans", "list", "--json"],
["scans", "compare", "before", "after", "--json"],
["scans", "match", "before", "after", "--json"],
]) {
const stdout = capture();
const stderr = capture();
const result = await main(argv, stdout.stream, stderr.stream, {
...dependencies({
onWorkbench: () => {
throw new Error(
"Scan ID prefixes must be at least eight characters.",
);
},
}),
});
expect(result).toBe(2);
expect(stdout.text()).toBe("");
expect(stderr.text()).toContain(
"Scan ID prefixes must be at least eight characters.",
);
}
});

test("shows finding history and optionally reveals linked findings", async () => {
const findings: JsonObject[] = [
{
Expand Down
Loading