{"record":{"id":"ebb8af806a941fd5","repo":"twentyhq/twenty","slug":"failed-to-create-record","errorCode":null,"errorMessage":"Failed to create record","messagePattern":"Failed to create record","errorType":"exception","errorClass":"CustomError","httpStatus":null,"severity":"error","filePath":"packages/twenty-front/src/modules/object-record/hooks/useCreateOneRecord.ts","lineNumber":213,"sourceCode":"        ? 'first'\n        : recordInput.position === 'last'\n          ? 'last'\n          : null;\n\n    const createdRecord = createdObject.data?.[\n      mutationResponseField\n    ] as ObjectRecordShared & BaseObjectRecord;\n\n    dispatchObjectRecordOperationBrowserEvent({\n      objectMetadataItem,\n      operation: {\n        type: 'create-one',\n        createdRecord: { ...createdRecord, position: positionToUse },\n      },\n    });\n\n    if (!isDefined(createdRecord)) {\n      throw new CustomError('Failed to create record');\n    }\n\n    return getRecordFromRecordNode({\n      recordNode: createdRecord,\n    });\n  };\n\n  return {\n    createOneRecord,\n    loading,\n  };\n};\n","sourceCodeStart":195,"sourceCodeEnd":226,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-front/src/modules/object-record/hooks/useCreateOneRecord.ts#L195-L226","documentation":"Thrown by useCreateOneRecord (useCreateOneRecord.ts:217-219) as a CustomError when the createOne GraphQL mutation response did not include the created record at the expected mutationResponseField. It is thrown AFTER a browser event has already been dispatched, indicating the mutation returned a malformed payload.","triggerScenarios":"The create record mutation resolves but `createdRecord` (destructured from the response at mutationResponseField) is undefined/null. isDefined(createdRecord) is false.","commonSituations":"Object metadata and mutationResponseField out of sync (stale metadata); GraphQL schema change where the field name no longer matches; server returning partial data due to an error swallowed at the resolver; Apollo cache returning a partial/incomplete object.","solutions":["Refresh object metadata and retry the create.","Inspect the mutation response in Apollo devtools to confirm the field name and shape.","Verify the mutationResponseField used by the hook matches the current GraphQL schema.","Check the server resolver logs for swallowed errors returning null data."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const hasCreatedRecord = <T>(r: T | null | undefined): r is T =>\n  isDefined(r);","tryCatchPattern":"try {\n  await createOneRecord(input);\n} catch (err) {\n  if (err instanceof CustomError && err.message === 'Failed to create record') {\n    // refetch metadata and let the user retry\n  }\n}","preventionTips":["Keep object metadata in sync with the GraphQL schema.","Refetch metadata before triggering create.","Inspect mutation responses in Apollo devtools during development.","Confirm the user has create permission before showing the form."],"tags":["frontend","object-record","graphql","apollo","mutation"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}