Skip to content

Commit a31bf68

Browse files
committed
Keep classified credential errors from being rewritten
sendFailureText rematched the #710 credential_failure line against raw-provider auth patterns and replaced it with the generic other copy. #711 tests still expected the pre-#710 session-expired string.
1 parent 92f9c00 commit a31bf68

4 files changed

Lines changed: 18 additions & 5 deletions

File tree

src/inference-error-message.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ import {
2020
type InferenceErrorLike,
2121
} from "./inference-gateway-error.js";
2222

23+
/** Committed auth death — do not claim a refresh is in flight. */
24+
export const CREDENTIAL_FAILURE_USER_MESSAGE = "Authentication failed — log in again.";
25+
2326
const FRIENDLY_BY_CATEGORY: Record<string, string> = {
24-
// Committed auth death — do not claim a refresh is in flight.
25-
credential_failure: "Authentication failed — log in again.",
27+
credential_failure: CREDENTIAL_FAILURE_USER_MESSAGE,
2628
quota_exhausted: "Quota exhausted — usage limit reached.",
2729
context_overflow:
2830
"Context window full — compaction could not keep up. Try /clear to start fresh.",

src/tui/runtime-bridge.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ describe("same-turn failover after inference.error", () => {
10241024

10251025
const text = shell.streamLog.map((r) => r.text).join("\n");
10261026
expect(text).toContain("next prompt");
1027-
expect(errorRows(shell)).toContain("Session expiredre-authenticating…");
1027+
expect(errorRows(shell)).toContain("Authentication failedlog in again.");
10281028
} finally {
10291029
bridge.dispose();
10301030
shell.dispose();
@@ -1096,7 +1096,7 @@ describe("same-turn failover after inference.error", () => {
10961096
const text = shell.streamLog.map((r) => r.text).join("\n");
10971097
expect(text).toContain("restart from here");
10981098
expect(text).toContain("stop — restarting from your message");
1099-
expect(errorRows(shell)).toContain("Session expiredre-authenticating…");
1099+
expect(errorRows(shell)).toContain("Authentication failedlog in again.");
11001100
} finally {
11011101
bridge.dispose();
11021102
shell.dispose();
@@ -1129,7 +1129,7 @@ describe("same-turn failover after inference.error", () => {
11291129
bridge.handle(event);
11301130
}
11311131

1132-
expect(errorRows(shell)).toContain("Session expiredre-authenticating…");
1132+
expect(errorRows(shell)).toContain("Authentication failedlog in again.");
11331133
} finally {
11341134
bridge.dispose();
11351135
shell.dispose();

src/tui/session-chrome.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,12 @@ describe("sendFailureText", () => {
261261
authProvider: null,
262262
});
263263
});
264+
265+
test("a classified credential_failure line is not rewritten as generic other", () => {
266+
expect(sendFailureText("Authentication failed — log in again.")).toBe(
267+
"Authentication failed — log in again.",
268+
);
269+
});
264270
});
265271

266272
describe("fleet state in the top-level indicator", () => {

src/tui/session-chrome.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* duplicating the state machine that produces it.
66
*/
77

8+
import { CREDENTIAL_FAILURE_USER_MESSAGE } from "../inference-error-message.js";
89
import type { Telemetry } from "../telemetry/index.js";
910
import type { FleetProgress } from "./agent-progress.js";
1011
import type { RampPhase } from "./ramp.js";
@@ -204,6 +205,10 @@ const AUTH_FAILURE_TEXT: Record<AuthProviderId, string> = {
204205
* the only detail the operator has.
205206
*/
206207
export function sendFailureText(message: string): string {
208+
// Classified inference.error lines are already operator-facing. Rematching
209+
// them against raw-provider auth patterns rewrites intentional copy
210+
// (e.g. "Authentication failed — log in again." → generic other).
211+
if (message === CREDENTIAL_FAILURE_USER_MESSAGE) return message;
207212
const failure = classifySendFailureMessage(message);
208213
if (failure.kind === "auth" && failure.authProvider !== null) {
209214
return AUTH_FAILURE_TEXT[failure.authProvider];

0 commit comments

Comments
 (0)