fix(ai): align dump status extraction
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import * as path from "node:path";
|
||||
import { extractHttpStatusFromError, getLogsDir, isBunTestRuntime } from "@oh-my-pi/pi-utils";
|
||||
import { getLogsDir, isBunTestRuntime } from "@oh-my-pi/pi-utils";
|
||||
import * as AIError from "../error/flags";
|
||||
import { isCopilotTransientModelError } from "./retry.js";
|
||||
import { formatErrorMessageWithRetryAfter } from "./retry-after.js";
|
||||
@@ -36,7 +36,7 @@ export function buildHttp400DumpPayload(
|
||||
): RawHttpRequestDump & { errorResponse: { status: number | undefined; message: string } } {
|
||||
return {
|
||||
...sanitizeDump(dump),
|
||||
errorResponse: { status: extractHttpStatusFromError(error), message },
|
||||
errorResponse: { status: AIError.status(error), message },
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,14 @@ describe("buildHttp400DumpPayload", () => {
|
||||
expect(payload.errorResponse).toEqual({ status: 400, message });
|
||||
});
|
||||
|
||||
it("records the same message-derived status that enables dumping", () => {
|
||||
const message = "400 Bad Request: image exceeds 5 MB limit";
|
||||
const error = new Error(message);
|
||||
|
||||
expect(shouldDumpRejectedRequest(error)).toBe(true);
|
||||
expect(buildHttp400DumpPayload(dump, error, message).errorResponse).toEqual({ status: 400, message });
|
||||
});
|
||||
|
||||
it("redacts sensitive request headers while keeping the rest", () => {
|
||||
const payload = buildHttp400DumpPayload(dump, new HttpError(400, "x"), "x");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user