{"record":{"id":"72f0cfff51329730","repo":"twentyhq/twenty","slug":"failed-to-create-view","errorCode":null,"errorMessage":"Failed to create view","messagePattern":"Failed to create view","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-front/src/modules/views/hooks/internal/usePerformViewAPIPersist.ts","lineNumber":60,"sourceCode":"              mainGroupByFieldMetadataId:\n                variables.input.mainGroupByFieldMetadataId,\n            });\n          }\n\n          return createViewMutation({\n            variables: {\n              input: {\n                ...variables.input,\n                id: newViewId,\n              },\n            },\n          });\n        },\n        applyResultToDraft: (mutationResult, { addToDraft }) => {\n          const newView = mutationResult.data?.createView;\n\n          if (!isDefined(newView)) {\n            throw new Error('Failed to create view');\n          }\n\n          const {\n            __typename,\n            viewFields: _viewFields,\n            viewFieldGroups: _viewFieldGroups,\n            viewFilters: _viewFilters,\n            viewFilterGroups: _viewFilterGroups,\n            viewSorts: _viewSorts,\n            viewGroups,\n            ...flatView\n          } = newView;\n\n          addToDraft({ key: 'views', items: [flatView as FlatView] });\n\n          // The server auto-creates viewGroups for Kanban views (mainGroupByFieldMetadataId)\n          addToDraft({\n            key: 'viewGroups',","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-front/src/modules/views/hooks/internal/usePerformViewAPIPersist.ts#L42-L78","documentation":"Thrown in usePerformViewAPIPersist when the createView mutation resolves but mutationResult.data.createView is undefined. The GraphQL response did not surface a thrown Apollo error, yet the createView payload is missing, so the optimistic-draft application cannot proceed.","triggerScenarios":"Server returns 200 with a populated errors array and `{ data: { createView: null } }`. Partial response from a network blip. Selection-set/codegen drift after a schema change.","commonSituations":"Permission denied creating a view (server returns null + error). Schema change to createView payload not yet codegen'd. Object metadata item id invalid.","solutions":["Inspect the raw GraphQL response (data + errors) in DevTools for the createView mutation.","Re-run `npx nx run twenty-front:graphql:generate --configuration=metadata`.","Verify the user has permission to create views on the target object."],"exampleFix":"// before: if (!isDefined(newView)) { throw new Error('Failed to create view'); }\n// after:  if (!isDefined(newView)) {\n//           throw new Error(mutationResult.errors?.[0]?.message ?? 'Failed to create view');\n//         }","handlingStrategy":"try-catch","validationCode":"const hasCreateViewPayload = (r: Awaited<ReturnType<typeof createViewMutation>>): boolean =>\n  isDefined(r?.data?.createView);","typeGuard":"const isCreateViewResult = (v: unknown): v is { id: string; name: string } =>\n  typeof v === 'object' && v !== null && typeof (v as any).id === 'string';","tryCatchPattern":"try {\n  await performViewAPICreate(variables, objectMetadataItemId);\n} catch (e) {\n  showError((e as Error).message); // 'Failed to create view'\n}","preventionTips":["Verify the user has create-view permission on the object before showing the action.","Keep generated metadata GraphQL in sync after schema changes.","Have the resolver populate errors so callers can show a meaningful message."],"tags":["views","graphql","apollo","metadata"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}