fix(wizard): include request_id in apply-batch payload
Backend EA2 apply-batch requires a request_id (idempotency key). Without it, every node/edge write after Intake was failing with HTTP 422 and the wizard stayed stuck on the Analyze phase. Verified via qa/audit_wizard_writes.mjs against the live URL: previously 1 successful POST (draft creation) + 6x 422, now full multi-phase write path enabled.
This commit is contained in:
@@ -61,16 +61,23 @@ export const wizardApi = {
|
||||
},
|
||||
|
||||
async applyBatch(flow_key: string, ops: BatchOperation[], actor: Actor, signal?: AbortSignal) {
|
||||
const request_id =
|
||||
typeof crypto !== "undefined" && "randomUUID" in crypto
|
||||
? crypto.randomUUID()
|
||||
: `req-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
|
||||
const res = await fetch(`${api.config.baseUrl}/api/ea2/apply-batch`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${sessionStorage.getItem("fm.mc.token.v1")}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ flow_key, ops, actor }),
|
||||
body: JSON.stringify({ flow_key, ops, actor, request_id }),
|
||||
signal,
|
||||
});
|
||||
if (!res.ok) throw new Error(`applyBatch failed: ${res.status}`);
|
||||
if (!res.ok) {
|
||||
const detail = await res.text().catch(() => "");
|
||||
throw new Error(`applyBatch ${res.status}: ${detail.slice(0, 200)}`);
|
||||
}
|
||||
return res.json();
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user