strapi/strapi · error
Content Type Definition is invalid for ${uid}'.\n${e.errors}
Error message
Content Type Definition is invalid for ${uid}'.\n${e.errors} What it means
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.
Source
Thrown at packages/core/core/src/domain/content-type/index.ts:27
actions: Record<string, unknown>;
lifecycles: Record<string, unknown>;
};
const {
CREATED_AT_ATTRIBUTE,
UPDATED_AT_ATTRIBUTE,
PUBLISHED_AT_ATTRIBUTE,
FIRST_PUBLISHED_AT_ATTRIBUTE,
CREATED_BY_ATTRIBUTE,
UPDATED_BY_ATTRIBUTE,
} = contentTypesUtils.constants;
const createContentType = (uid: string, definition: ContentTypeDefinition) => {
try {
validateContentTypeDefinition(definition);
} catch (e) {
if (e instanceof yup.ValidationError) {
throw new Error(`Content Type Definition is invalid for ${uid}'.\n${e.errors}`);
}
throw e;
}
const { schema, actions, lifecycles } = cloneDeep(definition);
// general info
Object.assign(schema, {
uid,
modelType: 'contentType',
kind: schema.kind || 'collectionType',
__schema__: pickSchema(definition.schema),
modelName: definition.schema.info.singularName,
actions,
lifecycles,
});
View on GitHub (pinned to 4a4101264d)
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.
Example fix
// before (schema.json)
{
"info": { "name": "Article" }, // missing singular/plural names
"attributes": { "title": { "type": "strin" } }
}
// after
{
"info": { "singularName": "article", "pluralName": "articles", "displayName": "Article" },
"attributes": { "title": { "type": "string" } }
} Defensive patterns
Strategy: validation
Validate before calling
import { validateContentTypeDefinition } from '@strapi/utils';
try { validateContentTypeDefinition(definition); }
catch (e) { console.error('Content type invalid:', e.errors); throw e; } Type guard
const hasRequiredInfo = (d: any): boolean => d?.schema?.info?.singularName && d?.schema?.info?.pluralName && d?.schema?.attributes;
Try / catch
try { createContentType(uid, definition); }
catch (e) {
if (e instanceof Error && /Content Type Definition is invalid/.test(e.message)) {
// e.message contains the yup error list; surface to content-type author
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Content type ${attribute.target} not found
- contentType.notFound
- contentType.invalidUID
- Unsupported attribute type: ${type}
- strapi-server.js is invalid for '${namespace}'.\n${e.errors.
AI-assisted analysis of strapi/strapi@4a4101264d (2026-08-12).
Data as JSON: /api/errors/d8a80231625630c2.
Report an issue: GitHub.