{"record":{"id":"075eb1f7c0f484a6","repo":"octobercms/october","slug":"cms-lang-template-invalid-type","errorCode":null,"errorMessage":"cms::lang.template.invalid_type","messagePattern":"cms::lang\\.template\\.invalid_type","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/cms/classes/editorextension/HasExtensionCrud.php","lineNumber":272,"sourceCode":"\n    /**\n     * resolveTypeClassName resolves a template type to its class name\n     * @param string $documentType\n     * @return string\n     */\n    private function resolveTypeClassName($documentType)\n    {\n        $types = [\n            EditorExtension::DOCUMENT_TYPE_PAGE => Page::class,\n            EditorExtension::DOCUMENT_TYPE_PARTIAL => Partial::class,\n            EditorExtension::DOCUMENT_TYPE_LAYOUT => Layout::class,\n            EditorExtension::DOCUMENT_TYPE_CONTENT => Content::class,\n            EditorExtension::DOCUMENT_TYPE_ASSET => Asset::class,\n            EditorExtension::DOCUMENT_TYPE_LANG => CmsLang::class\n        ];\n\n        if (!array_key_exists($documentType, $types)) {\n            throw new SystemException(trans('cms::lang.template.invalid_type'));\n        }\n\n        return $types[$documentType];\n    }\n\n    /**\n     * makeMetadataForNewTemplate builds meta data for new templates\n     */\n    protected function makeMetadataForNewTemplate(string $documentType): array\n    {\n        return [\n            'mtime' => null,\n            'path' => null,\n            'theme' => ($theme = $this->getTheme()) ? $theme->getDirName() : null,\n            'type' => $documentType,\n            'isNewDocument' => true\n        ];\n    }","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/cms/classes/editorextension/HasExtensionCrud.php#L254-L290","documentation":"resolveTypeClassName() maps the request's document type to a Halcyon template class and accepts only the six known types: page, partial, layout, content, asset and lang (EditorExtension constants). Any other string throws 'Unknown template type.'","triggerScenarios":"An editor-extension request whose documentData/extraData 'type' is not one of the EditorExtension::DOCUMENT_TYPE_* values — custom types, misspellings ('Page', 'pages'), or a type vocabulary from a different Winter version.","commonSituations":"Custom integrations inventing type names; hand-built JS payloads; older editor bundles running against a newer backend (or vice versa) where the set of types differs (e.g. 'lang' does not exist on older versions).","solutions":["Use one of the exact supported type strings: 'page', 'partial', 'layout', 'content', 'asset', 'lang'","Check for typos and casing in the type field","Align the editor JS bundle and PHP backend to the same Winter version so type vocabularies match"],"exampleFix":"// before\n['type' => 'pages', 'key' => 'index.htm']\n\n// after\n['type' => 'page', 'key' => 'index.htm']","handlingStrategy":"type-guard","validationCode":"$allowed = ['page', 'partial', 'layout', 'content', 'asset', 'lang'];\nif (!in_array($type, $allowed, true)) {\n    // reject unknown types before any editor-extension call\n    throw new InvalidArgumentException('Unsupported document type: '.$type);\n}","typeGuard":"const DOCUMENT_TYPES = new Set(['page', 'partial', 'layout', 'content', 'asset', 'lang']);\nfunction isDocumentType(t) {\n  return typeof t === 'string' && DOCUMENT_TYPES.has(t);\n}","tryCatchPattern":null,"preventionTips":["Source type strings from the same EditorExtension constants on both client and server","Pin client and server to the same Winter version in CI to catch vocabulary drift","Reject unknown types early in custom integrations with a clear message"],"tags":["editor","document-type","cms","api-contract","validation"],"backgroundTag":"unknown-document-type","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}