authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-06-20 12:33:22-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-06-20 12:33:22-07:00
log621616268af212c9550aecc883b75beb42b3c1bd
tree1cb7b7c608bed5ddd5d19f91721d5ec52fea408b
parent630df6b986f6e254d3c564da639de5b7b52fe95d
signature Signed by PGP key B5690EEEBB952194

[codex] Sanitize text generation CLI errors (#3431)

Co-authored-by: codex <codex@users.noreply.github.com>

2 files changed, 13 insertions(+), 1 deletions(-)

apps/server/src/textGeneration/TextGenerationPrompts.test.ts+12
...@@ -190,4 +190,16 @@ describe("normalizeCliError", () => {...@@ -190,4 +190,16 @@ describe("normalizeCliError", () => {
190 expect(result).toBeInstanceOf(TextGenerationError);190 expect(result).toBeInstanceOf(TextGenerationError);
191 expect(result.detail).toBe("fallback");191 expect(result.detail).toBe("fallback");
192 });192 });
193
194 it("does not expose CLI failure details in the public error message", () => {
195 const result = normalizeCliError(
196 "codex",
197 "generateCommitMessage",
198 new Error("request failed with access_token=secret-token"),
199 "Failed to generate a commit message",
200 );
201
202 expect(result.detail).toBe("Failed to generate a commit message");
203 expect(result.message).not.toContain("secret-token");
204 });
193});205});
apps/server/src/textGeneration/TextGenerationUtils.ts+1-1
...@@ -99,7 +99,7 @@ export function normalizeCliError(...@@ -99,7 +99,7 @@ export function normalizeCliError(
99 }99 }
100 return new TextGenerationError({100 return new TextGenerationError({
101 operation,101 operation,
102 detail: `${fallback}: ${error.message}`,102 detail: fallback,
103 cause: error,103 cause: error,
104 });104 });
105 }105 }