{"record":{"id":"d8a80231625630c2","repo":"strapi/strapi","slug":"content-type-definition-is-invalid-for-uid-n","errorCode":null,"errorMessage":"Content Type Definition is invalid for ${uid}'.\\n${e.errors}","messagePattern":"Content Type Definition is invalid for (.+?)'\\.\\\\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/core/src/domain/content-type/index.ts","lineNumber":27,"sourceCode":"  actions: Record<string, unknown>;\n  lifecycles: Record<string, unknown>;\n};\n\nconst {\n  CREATED_AT_ATTRIBUTE,\n  UPDATED_AT_ATTRIBUTE,\n  PUBLISHED_AT_ATTRIBUTE,\n  FIRST_PUBLISHED_AT_ATTRIBUTE,\n  CREATED_BY_ATTRIBUTE,\n  UPDATED_BY_ATTRIBUTE,\n} = contentTypesUtils.constants;\n\nconst createContentType = (uid: string, definition: ContentTypeDefinition) => {\n  try {\n    validateContentTypeDefinition(definition);\n  } catch (e) {\n    if (e instanceof yup.ValidationError) {\n      throw new Error(`Content Type Definition is invalid for ${uid}'.\\n${e.errors}`);\n    }\n\n    throw e;\n  }\n\n  const { schema, actions, lifecycles } = cloneDeep(definition);\n\n  // general info\n  Object.assign(schema, {\n    uid,\n    modelType: 'contentType',\n    kind: schema.kind || 'collectionType',\n    __schema__: pickSchema(definition.schema),\n    modelName: definition.schema.info.singularName,\n    actions,\n    lifecycles,\n  });\n","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/strapi/strapi/blob/4a4101264d7098754df36e85fa629fd2f2349d8c/packages/core/core/src/domain/content-type/index.ts#L9-L45","documentation":"Thrown by createContentType() when `validateContentTypeDefinition(definition)` raises a yup ValidationError. This means the raw content-type definition object (schema + actions + lifecycles) failed structural validation — e.g. missing required schema.info fields, invalid attribute shapes, wrong kind. The yup error list is appended so the developer sees every violated constraint.","triggerScenarios":"A content type is registered (via a plugin, component, or API) whose definition fails validateContentTypeDefinition: missing schema.info.singularName, unknown attribute configuration, wrong `kind` value, or malformed options. createContentType catches the yup ValidationError and rethrows this aggregated Error.","commonSituations":"Hand-writing schema.json and omitting required info fields (singularName/pluralName); using a custom-field or attribute option unsupported in the current Strapi version; plugin providing a content type with an outdated schema shape after an upgrade; content-type-builder-generated file manually corrupted.","solutions":["Read the appended yup `e.errors` list — each line names the failing field and constraint; fix each in schema.json.","Ensure schema.info contains at least singularName and pluralName in kebab-case, and that `kind` is 'collectionType' or 'singleType'.","Validate attribute definitions against the Strapi attribute schema (use the Content-Type Builder UI to regenerate).","After a Strapi version bump, re-run the content type through the builder or migration tooling."],"exampleFix":"// before (schema.json)\n{\n  \"info\": { \"name\": \"Article\" }, // missing singular/plural names\n  \"attributes\": { \"title\": { \"type\": \"strin\" } }\n}\n\n// after\n{\n  \"info\": { \"singularName\": \"article\", \"pluralName\": \"articles\", \"displayName\": \"Article\" },\n  \"attributes\": { \"title\": { \"type\": \"string\" } }\n}","handlingStrategy":"validation","validationCode":"import { validateContentTypeDefinition } from '@strapi/utils';\ntry { validateContentTypeDefinition(definition); }\ncatch (e) { console.error('Content type invalid:', e.errors); throw e; }","typeGuard":"const hasRequiredInfo = (d: any): boolean =>\n  d?.schema?.info?.singularName && d?.schema?.info?.pluralName && d?.schema?.attributes;","tryCatchPattern":"try { createContentType(uid, definition); }\ncatch (e) {\n  if (e instanceof Error && /Content Type Definition is invalid/.test(e.message)) {\n    // e.message contains the yup error list; surface to content-type author\n  } else throw e;\n}","preventionTips":["Always include schema.info.singularName and pluralName in kebab-case.","Validate definitions with validateContentTypeDefinition in unit tests.","Generate content types with the builder to keep schema shapes valid."],"tags":["content-type","schema","validation","startup","yup"],"backgroundTag":null,"analyzedSha":"4a4101264d7098754df36e85fa629fd2f2349d8c","analyzedAt":"2026-08-12T12:47:50.760Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}