strapi/strapi · error · ApplicationError

contentType.alreadyExists

Error message

contentType.alreadyExists

What it means

Thrown by ContentTypeBuilder.createContentType when the resolved uid already exists in the builder's contentTypes map. Prevents creating two content types with the same identifier.

Source

Thrown at packages/core/content-type-builder/server/src/services/schema-builder/content-type-builder.ts:156

      });

      return contentType;
    },

    /**
     * Creates a content type in memory to be written to files later on
     */
    createContentType(this: any, infos: CreateContentTypeInput) {
      // TODO:: check for unique uid / singularName & pluralName & collectionName

      if (infos.uid && infos.uid !== createContentTypeUID(infos)) {
        throw new ApplicationError('contentType.invalidUID');
      }

      const uid = infos.uid ?? createContentTypeUID(infos);

      if (this.contentTypes.has(uid)) {
        throw new ApplicationError('contentType.alreadyExists');
      }

      const dir = infos.plugin
        ? path.join(strapi.dirs.app.extensions, infos.plugin, 'content-types', infos.singularName)
        : path.join(strapi.dirs.app.api, infos.singularName, 'content-types', infos.singularName);

      const contentType = createSchemaHandler({
        modelName: infos.singularName,
        dir,
        filename: `schema.json`,
      });

      this.contentTypes.set(uid, contentType);

      contentType
        .setUID(uid)
        .set('kind', infos.kind || typeKinds.COLLECTION_TYPE)
        .set(

View on GitHub (pinned to 4a4101264d)

Solutions

  1. Use editContentType for an existing content type instead of createContentType.
  2. Choose a unique singularName (and therefore uid).
  3. Check src/api and src/extensions for an existing content type with that uid.
Defensive patterns

Strategy: validation

Validate before calling

function isDuplicateContentType(builder: any, uid: string): boolean {
  return builder.contentTypes.has(uid);
}

Try / catch

try {
  builder.createContentType(infos);
} catch (err) {
  if (err?.message === 'contentType.alreadyExists' && builder.contentTypes.has(uid)) {
    builder.editContentType({ ...infos, uid });
  } else throw err;
}

Prevention

When it happens

Trigger: createContentType called with a uid that already exists — duplicate create request, or a content type with the same singularName already on disk.

Common situations: User clicks Create twice; a content type was previously created with the same singularName; migration/import duplicates an existing type.

Related errors


AI-assisted analysis of strapi/strapi@4a4101264d (2026-08-12). Data as JSON: /api/errors/dc5a248a498910a6. Report an issue: GitHub.