{"record":{"id":"d552cd5df258b82a","repo":"twentyhq/twenty","slug":"could-not-find-standard-entity-universalidentifi","errorCode":null,"errorMessage":"Could not find standard entity ${universalIdentifier}","messagePattern":"Could not find standard entity (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/twenty-server/src/database/commands/upgrade-version-command/2-10/utils/get-standard-flat-entities-to-create-or-throw.util.ts","lineNumber":22,"sourceCode":"import { type FlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/types/flat-entity-maps.type';\n\nexport const getStandardFlatEntitiesToCreateOrThrow = <\n  T extends SyncableFlatEntity,\n>({\n  standardFlatEntityMaps,\n  existingFlatEntityMaps,\n  universalIdentifiers,\n}: {\n  standardFlatEntityMaps: FlatEntityMaps<T>;\n  existingFlatEntityMaps: FlatEntityMaps<T>;\n  universalIdentifiers: string[];\n}): T[] =>\n  universalIdentifiers.flatMap((universalIdentifier) => {\n    const standardFlatEntity =\n      standardFlatEntityMaps.byUniversalIdentifier[universalIdentifier];\n\n    if (!isDefined(standardFlatEntity)) {\n      throw new Error(`Could not find standard entity ${universalIdentifier}`);\n    }\n\n    if (\n      isDefined(\n        existingFlatEntityMaps.byUniversalIdentifier[universalIdentifier],\n      )\n    ) {\n      return [];\n    }\n\n    return [standardFlatEntity];\n  });\n\nexport const getExistingOrStandardFlatEntityOrThrow = <\n  T extends SyncableFlatEntity,\n>({\n  standardFlatEntityMaps,\n  existingFlatEntityMaps,","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-server/src/database/commands/upgrade-version-command/2-10/utils/get-standard-flat-entities-to-create-or-throw.util.ts#L4-L40","documentation":"Thrown by getStandardFlatEntitiesToCreateOrThrow when a requested universalIdentifier is not present in standardFlatEntityMaps.byUniversalIdentifier. This signals a contract mismatch: the caller asked for a standard entity the installed standard-metadata build does not define. The function then skips any that already exist in the workspace.","triggerScenarios":"Passing a universalIdentifier list that includes an id absent from the standard flat entity maps — e.g. a constant from a newer/older twenty-shared metadata version than the server build, or a copy-paste typo in an identifier.","commonSituations":"Version skew between twenty-shared/metadata STANDARD_OBJECTS and the command code; an upgrade command references a standard entity introduced in a later build; identifier typo or stale hardcoded UUID.","solutions":["Verify every universalIdentifier passed in exists in standardFlatEntityMaps.byUniversalIdentifier for the installed build.","Align twenty-shared/metadata and twenty-server to the same version so STANDARD_OBJECTS includes the referenced entity.","Correct any typo'd or hardcoded UUID in the calling command."],"exampleFix":"// before: passes identifiers blindly, throws if any is missing\nconst toCreate = getStandardFlatEntitiesToCreateOrThrow({\n  standardFlatEntityMaps,\n  existingFlatEntityMaps,\n  universalIdentifiers,\n});\n\n// after: filter to known standards first\nconst known = universalIdentifiers.filter((id) =>\n  isDefined(standardFlatEntityMaps.byUniversalIdentifier[id]),\n);\nconst toCreate = getStandardFlatEntitiesToCreateOrThrow({\n  standardFlatEntityMaps,\n  existingFlatEntityMaps,\n  universalIdentifiers: known,\n});","handlingStrategy":"type-guard","validationCode":"import { isDefined } from 'twenty-shared/utils';\n\n// Filter to identifiers that actually exist in the standard map before calling:\nconst known = universalIdentifiers.filter((id) =>\n  isDefined(standardFlatEntityMaps.byUniversalIdentifier[id]),\n);\nconst toCreate = getStandardFlatEntitiesToCreateOrThrow({\n  standardFlatEntityMaps,\n  existingFlatEntityMaps,\n  universalIdentifiers: known,\n});","typeGuard":"import { isDefined } from 'twenty-shared/utils';\n\nconst isKnownStandardEntity = <T>(\n  standardFlatEntityMaps: { byUniversalIdentifier: Record<string, T | undefined> },\n  universalIdentifier: string,\n): universalIdentifier is string & keyof typeof standardFlatEntityMaps.byUniversalIdentifier =>\n  isDefined(standardFlatEntityMaps.byUniversalIdentifier[universalIdentifier]);","tryCatchPattern":null,"preventionTips":["Validate every universalIdentifier against the standard map before passing it in.","Keep twenty-shared/metadata and twenty-server on the same version so STANDARD_OBJECTS includes all referenced entities.","Avoid hardcoding UUIDs; reference them via the shared STANDARD_OBJECTS constant."],"tags":["metadata","standard-entities","data-integrity","version-skew"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}