{"record":{"id":"681ba0d343c7f14f","repo":"BloopAI/vibe-kanban","slug":"failed-to-create-mutation-name-or-server-provi","errorCode":null,"errorMessage":"Failed to create ${mutation.name} (or server-provided message via parseResponseError)","messagePattern":"Failed to create (.+?) \\(or server-provided message via parseResponseError\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/web-core/src/shared/lib/electric/collections.ts","lineNumber":643,"sourceCode":") {\n  return {\n    onInsert: async ({\n      transaction,\n    }: MutationFnParams): Promise<{ txid: number[] } | void> => {\n      const txids = await Promise.all(\n        transaction.mutations.map(async (mutationItem) => {\n          const data = mutationItem.modified as Record<string, unknown>;\n          const response = await makeRequest(mutation.url, {\n            method: 'POST',\n            body: JSON.stringify(data),\n          });\n\n          if (!response.ok) {\n            const message = await parseResponseError(\n              response,\n              `Failed to create ${mutation.name}`\n            );\n            throw new Error(message);\n          }\n\n          const result = (await response.json()) as { txid: number };\n          return result.txid;\n        })\n      );\n\n      maybeRefreshFallbackAfterMutation(sourceKey);\n\n      if (isSourceFallbackLocked(sourceKey)) {\n        return;\n      }\n\n      return { txid: txids };\n    },\n\n    onUpdate: async ({\n      transaction,","sourceCodeStart":625,"sourceCodeEnd":661,"githubUrl":"https://github.com/BloopAI/vibe-kanban/blob/4deb7eca8f381f7cbc1f9d15515a9ab8f8009053/packages/web-core/src/shared/lib/electric/collections.ts#L625-L661","documentation":"The onInsert mutation handler POSTs each inserted row to mutation.url and, on a non-ok response, throws an Error whose message comes from parseResponseError — the server's `message`/`error` field, or the fallback 'Failed to create <name>'. This aborts the optimistic transaction, so Electric rolls back the local insert.","triggerScenarios":"POST to the mutation endpoint fails validation (400/422), user lacks permission (403), session expired (401), the record conflicts (409), or the route returns 500; also thrown per-item inside Promise.all so any one failing insert rejects the whole transaction.","commonSituations":"Required field missing from the new row per server-side validation; optimistic UI allowed an edit the server rejects; token expired mid-session; server enforces uniqueness the client didn't check; mutation.url points at a stale/wrong API path after refactor.","solutions":["Read the thrown message — it usually contains the server's validation reason (parseResponseError surfaced it).","Validate the row against server schema before optimistic insert (zod schema shared via shared/schemas).","Handle 401 by refreshing auth and retrying the transaction.","Confirm mutation.url is the correct create endpoint and accepts the exact JSON body being sent."],"exampleFix":"// before\nawait collection.insert(data); // throws on server rejection\n// after\nconst parsed = taskCreateSchema.safeParse(data);\nif (!parsed.success) { showError(parsed.error); return; }\nawait collection.insert(parsed.data);","handlingStrategy":"try-catch","validationCode":"const parsed = createSchema.safeParse(data);\nif (!parsed.success) {\n  showError(parsed.error.message);\n  return;\n}","typeGuard":"function isCreateFailure(msg: string): boolean {\n  return msg.startsWith('Failed to create ');\n}","tryCatchPattern":"try {\n  await collection.insert(data);\n} catch (e) {\n  if (isCreateFailure(e.message)) {\n    showToast(e.message); // server-provided reason surfaced by parseResponseError\n    return; // optimistic insert is rolled back automatically\n  }\n  throw e;\n}","preventionTips":["Validate against the shared zod schema before optimistic insert","Keep mutation.url in sync with the backend create route","Refresh auth tokens proactively to avoid mid-edit 401s","Check server-side uniqueness constraints client-side first"],"tags":["electric-sql","mutations","http-error","validation"],"backgroundTag":"api-non-2xx-response","analyzedSha":"4deb7eca8f381f7cbc1f9d15515a9ab8f8009053","analyzedAt":"2026-08-29T09:24:13.446Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}