twentyhq/twenty · critical · Error

Could not find standard entity ${universalIdentifier}

Error message

Could not find standard entity ${universalIdentifier}

What it means

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.

Source

Thrown at packages/twenty-server/src/database/commands/upgrade-version-command/2-10/utils/get-standard-flat-entities-to-create-or-throw.util.ts:22

import { type FlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/types/flat-entity-maps.type';

export const getStandardFlatEntitiesToCreateOrThrow = <
  T extends SyncableFlatEntity,
>({
  standardFlatEntityMaps,
  existingFlatEntityMaps,
  universalIdentifiers,
}: {
  standardFlatEntityMaps: FlatEntityMaps<T>;
  existingFlatEntityMaps: FlatEntityMaps<T>;
  universalIdentifiers: string[];
}): T[] =>
  universalIdentifiers.flatMap((universalIdentifier) => {
    const standardFlatEntity =
      standardFlatEntityMaps.byUniversalIdentifier[universalIdentifier];

    if (!isDefined(standardFlatEntity)) {
      throw new Error(`Could not find standard entity ${universalIdentifier}`);
    }

    if (
      isDefined(
        existingFlatEntityMaps.byUniversalIdentifier[universalIdentifier],
      )
    ) {
      return [];
    }

    return [standardFlatEntity];
  });

export const getExistingOrStandardFlatEntityOrThrow = <
  T extends SyncableFlatEntity,
>({
  standardFlatEntityMaps,
  existingFlatEntityMaps,

View on GitHub (pinned to 1f5dd2bbd2)

Solutions

  1. Verify every universalIdentifier passed in exists in standardFlatEntityMaps.byUniversalIdentifier for the installed build.
  2. Align twenty-shared/metadata and twenty-server to the same version so STANDARD_OBJECTS includes the referenced entity.
  3. Correct any typo'd or hardcoded UUID in the calling command.

Example fix

// before: passes identifiers blindly, throws if any is missing
const toCreate = getStandardFlatEntitiesToCreateOrThrow({
  standardFlatEntityMaps,
  existingFlatEntityMaps,
  universalIdentifiers,
});

// after: filter to known standards first
const known = universalIdentifiers.filter((id) =>
  isDefined(standardFlatEntityMaps.byUniversalIdentifier[id]),
);
const toCreate = getStandardFlatEntitiesToCreateOrThrow({
  standardFlatEntityMaps,
  existingFlatEntityMaps,
  universalIdentifiers: known,
});
Defensive patterns

Strategy: type-guard

Validate before calling

import { isDefined } from 'twenty-shared/utils';

// Filter to identifiers that actually exist in the standard map before calling:
const known = universalIdentifiers.filter((id) =>
  isDefined(standardFlatEntityMaps.byUniversalIdentifier[id]),
);
const toCreate = getStandardFlatEntitiesToCreateOrThrow({
  standardFlatEntityMaps,
  existingFlatEntityMaps,
  universalIdentifiers: known,
});

Type guard

import { isDefined } from 'twenty-shared/utils';

const isKnownStandardEntity = <T>(
  standardFlatEntityMaps: { byUniversalIdentifier: Record<string, T | undefined> },
  universalIdentifier: string,
): universalIdentifier is string & keyof typeof standardFlatEntityMaps.byUniversalIdentifier =>
  isDefined(standardFlatEntityMaps.byUniversalIdentifier[universalIdentifier]);

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of twentyhq/twenty@1f5dd2bbd2 (2026-08-12). Data as JSON: /api/errors/d552cd5df258b82a. Report an issue: GitHub.