octobercms/october · error · SystemException
Document type name is not defined: %s
Error message
Document type name is not defined: %s
What it means
loadTemplateMetadata() builds the typeName label shown in the editor from a map keyed by the two tailor document types. If documentData.type is not a key in that map, it throws sprintf('Document type name is not defined: %s') — a type that slipped past earlier validation and reached metadata building.
Source
Thrown at modules/tailor/classes/editorextension/HasExtensionCrud.php:265
'path' => null,
'type' => $documentType,
'isNewDocument' => true
];
}
/**
* loadTemplateMetadata
*/
private function loadTemplateMetadata($template, $documentData)
{
$typeNames = [
EditorExtension::DOCUMENT_TYPE_BLUEPRINT => Lang::get('tailor::lang.editor.blueprint'),
EditorExtension::DOCUMENT_TYPE_THEME_BLUEPRINT => Lang::get('tailor::lang.editor.blueprint')
];
$documentType = $documentData['type'];
if (!array_key_exists($documentType, $typeNames)) {
throw new SystemException(sprintf('Document type name is not defined: %s', $documentData['type']));
}
$fileName = ltrim($template->fileName, '/');
$result = [
'mtime' => $template->mtime,
'path' => $fileName,
'type' => $documentType,
'typeName' => $typeNames[$documentType]
];
return $result;
}
/**
* getRequestMetadata
*/
private function getRequestMetadata()View on GitHub (pinned to b608633a7e)
Solutions
- Use only EditorExtension::DOCUMENT_TYPE_BLUEPRINT / DOCUMENT_TYPE_THEME_BLUEPRINT for `type`.
- Call assertDocumentTypePermissions($documentType) at the entry of every custom handler so bad types fail early with a clear permission/unknown-type error.
Example fix
// before $metadata = $this->loadTemplateMetadata($template, $documentData); // after $this->assertDocumentTypePermissions($documentData['type']); $metadata = $this->loadTemplateMetadata($template, $documentData);
Defensive patterns
Strategy: type-guard
Validate before calling
$typeNames = [
\Tailor\Classes\EditorExtension::DOCUMENT_TYPE_BLUEPRINT,
\Tailor\Classes\EditorExtension::DOCUMENT_TYPE_THEME_BLUEPRINT,
];
if (!in_array($documentData['type'] ?? null, $typeNames, true)) {
throw new InvalidArgumentException('Document type name not defined');
} Type guard
function hasMetadataTypeName($type): bool
{
return in_array($type, [
\Tailor\Classes\EditorExtension::DOCUMENT_TYPE_BLUEPRINT,
\Tailor\Classes\EditorExtension::DOCUMENT_TYPE_THEME_BLUEPRINT,
], true);
} Try / catch
try {
$metadata = $this->loadTemplateMetadata($template, $documentData);
} catch (\SystemException $e) {
// type slipped through earlier validation; reject payload and log the offending type
} Prevention
- Route every custom handler through assertDocumentTypePermissions() so unknown types fail early.
- Keep type validation in one place (request boundary) instead of per-helper.
When it happens
Trigger: A request whose documentData.type is anything other than 'tailor-blueprint'/'tailor-theme-blueprint' reaches loadTemplateMetadata(), typically via custom handlers that skip assertDocumentTypePermissions().
Common situations: Custom editor-extension integrations forwarding unvalidated types; inconsistent payloads between the open and save requests; extensions registering new document types without updating this map.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Unknown template type.
- Unknown document type: %s
- cms::lang.template.invalid_type
- Type must be one of: {$typeAsString}.
- Invalid field name: {$fieldName}.
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/2cc256f787b8f240.
Report an issue: GitHub.