{"record":{"id":"dc5a248a498910a6","repo":"strapi/strapi","slug":"contenttype-alreadyexists","errorCode":null,"errorMessage":"contentType.alreadyExists","messagePattern":"contentType\\.alreadyExists","errorType":"exception","errorClass":"ApplicationError","httpStatus":null,"severity":"error","filePath":"packages/core/content-type-builder/server/src/services/schema-builder/content-type-builder.ts","lineNumber":156,"sourceCode":"      });\n\n      return contentType;\n    },\n\n    /**\n     * Creates a content type in memory to be written to files later on\n     */\n    createContentType(this: any, infos: CreateContentTypeInput) {\n      // TODO:: check for unique uid / singularName & pluralName & collectionName\n\n      if (infos.uid && infos.uid !== createContentTypeUID(infos)) {\n        throw new ApplicationError('contentType.invalidUID');\n      }\n\n      const uid = infos.uid ?? createContentTypeUID(infos);\n\n      if (this.contentTypes.has(uid)) {\n        throw new ApplicationError('contentType.alreadyExists');\n      }\n\n      const dir = infos.plugin\n        ? path.join(strapi.dirs.app.extensions, infos.plugin, 'content-types', infos.singularName)\n        : path.join(strapi.dirs.app.api, infos.singularName, 'content-types', infos.singularName);\n\n      const contentType = createSchemaHandler({\n        modelName: infos.singularName,\n        dir,\n        filename: `schema.json`,\n      });\n\n      this.contentTypes.set(uid, contentType);\n\n      contentType\n        .setUID(uid)\n        .set('kind', infos.kind || typeKinds.COLLECTION_TYPE)\n        .set(","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/strapi/strapi/blob/4a4101264d7098754df36e85fa629fd2f2349d8c/packages/core/content-type-builder/server/src/services/schema-builder/content-type-builder.ts#L138-L174","documentation":"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.","triggerScenarios":"createContentType called with a uid that already exists — duplicate create request, or a content type with the same singularName already on disk.","commonSituations":"User clicks Create twice; a content type was previously created with the same singularName; migration/import duplicates an existing type.","solutions":["Use editContentType for an existing content type instead of createContentType.","Choose a unique singularName (and therefore uid).","Check src/api and src/extensions for an existing content type with that uid."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function isDuplicateContentType(builder: any, uid: string): boolean {\n  return builder.contentTypes.has(uid);\n}","typeGuard":null,"tryCatchPattern":"try {\n  builder.createContentType(infos);\n} catch (err) {\n  if (err?.message === 'contentType.alreadyExists' && builder.contentTypes.has(uid)) {\n    builder.editContentType({ ...infos, uid });\n  } else throw err;\n}","preventionTips":["Use editContentType for existing uids.","Choose unique singularNames.","Disable submit while a request is in flight."],"tags":["content-type-builder","content-type","schema","duplicate","uid"],"backgroundTag":null,"analyzedSha":"4a4101264d7098754df36e85fa629fd2f2349d8c","analyzedAt":"2026-08-12T12:47:50.760Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}