fix(cli): align structured output guard with native flags (#777)

Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com>
This commit is contained in:
Rudy Mizrahi Celekli
2026-10-07 10:51:21 +08:00
committed by GitHub
parent 5a0e0ba3b8
commit e9fac56232
2 changed files with 21 additions and 5 deletions
+19
View File
@@ -57,6 +57,25 @@ describe("CLI output argument and sanitization boundary", () => {
).toEqual({ ok: true });
});
workspaceCliTest(
"preserves complete JSON errors when native builtin flags follow unusual arguments",
async ({ cli }) => {
for (const arguments_ of [
["providers", "--", "--json", "--token-limit", "5"],
["providers", "--json", "--format=toon", "--token-limit", "5"],
]) {
const result = await cli.run({ arguments: arguments_ });
expect(result.exitCode).toBe(1);
expect(result.stdout).not.toContain("[truncated:");
expect(JSON.parse(result.stdout)).toMatchObject({
ok: false,
error: { code: "UNSUPPORTED_OUTPUT_COMBINATION" },
});
}
},
CLI_INTEGRATION_TIMEOUT_MS,
);
workspaceCliTest(
"fails before emitting a truncated JSON document",
async ({ cli }) => {