{"record":{"id":"c151261d1f65abb9","repo":"octobercms/october","slug":"document-type-name-is-not-defined-s","errorCode":null,"errorMessage":"Document type name is not defined: %s","messagePattern":"Document type name is not defined: (.+?)","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/cms/classes/editorextension/HasExtensionCrud.php","lineNumber":311,"sourceCode":"     * loadTemplateMetadata\n     */\n    private function loadTemplateMetadata($template, $documentData)\n    {\n        $theme = $this->getTheme();\n        $themeDirName = $theme->getDirName();\n\n        $typeNames = [\n            EditorExtension::DOCUMENT_TYPE_PAGE => Lang::get('cms::lang.editor.page'),\n            EditorExtension::DOCUMENT_TYPE_LAYOUT => Lang::get('cms::lang.editor.layout'),\n            EditorExtension::DOCUMENT_TYPE_PARTIAL => Lang::get('cms::lang.editor.partial'),\n            EditorExtension::DOCUMENT_TYPE_CONTENT => Lang::get('cms::lang.editor.content'),\n            EditorExtension::DOCUMENT_TYPE_ASSET => Lang::get('cms::lang.editor.asset'),\n            EditorExtension::DOCUMENT_TYPE_LANG => Lang::get('cms::lang.editor.lang')\n        ];\n\n        $documentType = $documentData['type'];\n        if (!array_key_exists($documentType, $typeNames)) {\n            throw new SystemException(sprintf('Document type name is not defined: %s', $documentData['type']));\n        }\n\n        $typeDirName = $this->getDocumentTypeDirName($template);\n        $fileName = ltrim($template->fileName, '/');\n\n        $result = [\n            'mtime' => $template->mtime,\n            'path' => $fileName,\n            'theme' => $themeDirName,\n            'canUpdateTemplateFile' => $this->canUpdateTemplateFile($template),\n            'canResetFromTemplateFile' => $this->canResetFromTemplateFile($template),\n            'fullPath' => $typeDirName.'/'.$fileName,\n            'type' => $documentType,\n            'typeName' => $typeNames[$documentType]\n        ];\n\n        return $result;\n    }","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/cms/classes/editorextension/HasExtensionCrud.php#L293-L329","documentation":"When building metadata for a loaded template, loadTemplateMetadata() looks up a human-readable type name in a fixed map of the six document types; a type missing from that map throws 'Document type name is not defined: %s'. In stock flows resolveTypeClassName() filters unknown types earlier, so this is reached mainly with custom or dynamically-injected document types.","triggerScenarios":"documentData['type'] resolves during loading (e.g. via a hooked event or third-party extension injecting custom types) but is not one of page|partial|layout|content|asset|lang when metadata is generated.","commonSituations":"Plugins adding custom editor document types without extending every type map; inconsistent payloads between editor commands; version drift where type maps across traits come from different module versions.","solutions":["Restrict requests to the six built-in document types","If you need custom types, hook the editor extension consistently so load, metadata and save all understand them","Upgrade Winter so all type maps come from the same version"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"$knownTypes = ['page', 'partial', 'layout', 'content', 'asset', 'lang'];\nif (!in_array($documentData['type'] ?? null, $knownTypes, true)) {\n    // do not build metadata for custom types; map them yourself before calling\n}","typeGuard":"function hasKnownTypeName(documentData) {\n  return ['page', 'partial', 'layout', 'content', 'asset', 'lang'].includes(documentData?.type);\n}","tryCatchPattern":null,"preventionTips":["When adding custom document types, extend every type map (load, metadata, save) consistently","Keep editor command payloads single-sourced instead of reassembling them per command"],"tags":["editor","document-type","cms","metadata","backend"],"backgroundTag":"unknown-document-type","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}