fix(confidence-engine): sanitize reasoning error responses

This commit is contained in:
2026-09-10 11:39:13 +01:00
parent b9d49ff277
commit 2cb2d556fd
11 changed files with 304 additions and 44 deletions
+2 -2
View File
@@ -360,7 +360,7 @@ describe("focused-deconstruct targetNodeId identity boundary", () => {
expect(json.providerExecution).toBeUndefined();
});
it("preserves the 500 provider-failure contract while logging structural diagnostics", async () => {
it("sanitizes generic provider failures while logging structural diagnostics", async () => {
const errorSpy = vi.spyOn(console, "error").mockImplementation(() => {});
vi.doMock("@/lib/llm/provider", () => ({
getProvider: () => ({
@@ -383,7 +383,7 @@ describe("focused-deconstruct targetNodeId identity boundary", () => {
}),
}));
expect(response.status).toBe(500);
await expect(response.json()).resolves.toEqual({ error: "provider failed" });
await expect(response.json()).resolves.toEqual({ error: "Reasoning request could not be completed." });
expect(errorSpy).toHaveBeenCalledWith(
"[api/focused-investigation/deconstruct] provider failure",
expect.objectContaining({ targetNodeId: "node-id", providerApiPath: "/v1/responses" }),