fix(confidence-engine): expose reconstruction validation issues
This commit is contained in:
@@ -105,12 +105,23 @@ describe("app/api/cases/start route", () => {
|
||||
});
|
||||
|
||||
it("returns provider/internal failures as 5xx without stack traces", async () => {
|
||||
const rawResponse = `{"reconstruction":{"observedStates":[{"id":"obs-1"${"x".repeat(2500)}}]}}`;
|
||||
mockStartCase.mockResolvedValue({
|
||||
success: false,
|
||||
error: "Provider unavailable",
|
||||
diagnostics: { modelName: "llama3" },
|
||||
statusCode: 502,
|
||||
rawResponse: '{"reconstruction":{"summary":""}}',
|
||||
analysisErrors: ["reconstruction: Required"],
|
||||
validationIssues: [
|
||||
{
|
||||
path: ["reconstruction", "observedStates", 2, "description"],
|
||||
code: "invalid_type",
|
||||
message: "Required",
|
||||
expected: "string",
|
||||
received: "undefined",
|
||||
},
|
||||
],
|
||||
rawResponse,
|
||||
});
|
||||
|
||||
const { POST } = await import("@/app/api/cases/start/route.js");
|
||||
@@ -125,7 +136,18 @@ describe("app/api/cases/start route", () => {
|
||||
expect(response.status).toBe(502);
|
||||
const body = await response.json();
|
||||
expect(body).toHaveProperty("rawResponse");
|
||||
expect(body.rawResponse).toBe('{"reconstruction":{"summary":""}}');
|
||||
expect(body.rawResponse).toBe(rawResponse);
|
||||
expect(body.rawResponse.length).toBeGreaterThan(2000);
|
||||
expect(body.analysisErrors).toEqual(["reconstruction: Required"]);
|
||||
expect(body.validationIssues).toEqual([
|
||||
expect.objectContaining({
|
||||
path: ["reconstruction", "observedStates", 2, "description"],
|
||||
code: "invalid_type",
|
||||
message: "Required",
|
||||
expected: "string",
|
||||
received: "undefined",
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
it("returns structured 500 on malformed JSON", async () => {
|
||||
|
||||
Reference in New Issue
Block a user