solver-api: standardize error contracts and harden parsing paths
Add structured 4xx responses and defensive parser/process behavior so clients receive consistent failures and malformed inputs are rejected deterministically. Made-with: Cursor
This commit is contained in:
@@ -78,6 +78,23 @@ describe("solver-api", () => {
|
||||
expect(Array.isArray(response.body.parsed.unsupportedFields)).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects /solve without xml and returns schema metadata", async () => {
|
||||
const app = buildApp();
|
||||
const response = await request(app).post("/solve").send({});
|
||||
expect(response.status).toBe(400);
|
||||
expect(response.body.schemaVersion).toBe(2);
|
||||
expect(response.body.code).toBe("missing_xml");
|
||||
});
|
||||
|
||||
it("rejects diagnostic workflow without surface card", async () => {
|
||||
const app = buildApp();
|
||||
const response = await request(app)
|
||||
.post("/solve")
|
||||
.send({ xml, solverModel: "fdm", workflow: "diagnostic" });
|
||||
expect(response.status).toBe(400);
|
||||
expect(response.body.code).toBe("missing_surface_card");
|
||||
});
|
||||
|
||||
it("is deterministic for the same input", async () => {
|
||||
const app = buildApp();
|
||||
const a = await request(app).post("/solve").send({ xml });
|
||||
|
||||
Reference in New Issue
Block a user