{"record":{"id":"2cc256f787b8f240","repo":"octobercms/october","slug":"document-type-name-is-not-defined-s-2cc256","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/tailor/classes/editorextension/HasExtensionCrud.php","lineNumber":265,"sourceCode":"            'path' => null,\n            'type' => $documentType,\n            'isNewDocument' => true\n        ];\n    }\n\n    /**\n     * loadTemplateMetadata\n     */\n    private function loadTemplateMetadata($template, $documentData)\n    {\n        $typeNames = [\n            EditorExtension::DOCUMENT_TYPE_BLUEPRINT => Lang::get('tailor::lang.editor.blueprint'),\n            EditorExtension::DOCUMENT_TYPE_THEME_BLUEPRINT => Lang::get('tailor::lang.editor.blueprint')\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        $fileName = ltrim($template->fileName, '/');\n\n        $result = [\n            'mtime' => $template->mtime,\n            'path' => $fileName,\n            'type' => $documentType,\n            'typeName' => $typeNames[$documentType]\n        ];\n\n        return $result;\n    }\n\n    /**\n     * getRequestMetadata\n     */\n    private function getRequestMetadata()","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/tailor/classes/editorextension/HasExtensionCrud.php#L247-L283","documentation":"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.","triggerScenarios":"A request whose documentData.type is anything other than 'tailor-blueprint'/'tailor-theme-blueprint' reaches loadTemplateMetadata(), typically via custom handlers that skip assertDocumentTypePermissions().","commonSituations":"Custom editor-extension integrations forwarding unvalidated types; inconsistent payloads between the open and save requests; extensions registering new document types without updating this map.","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."],"exampleFix":"// before\n$metadata = $this->loadTemplateMetadata($template, $documentData);\n\n// after\n$this->assertDocumentTypePermissions($documentData['type']);\n$metadata = $this->loadTemplateMetadata($template, $documentData);","handlingStrategy":"type-guard","validationCode":"$typeNames = [\n    \\Tailor\\Classes\\EditorExtension::DOCUMENT_TYPE_BLUEPRINT,\n    \\Tailor\\Classes\\EditorExtension::DOCUMENT_TYPE_THEME_BLUEPRINT,\n];\nif (!in_array($documentData['type'] ?? null, $typeNames, true)) {\n    throw new InvalidArgumentException('Document type name not defined');\n}","typeGuard":"function hasMetadataTypeName($type): bool\n{\n    return in_array($type, [\n        \\Tailor\\Classes\\EditorExtension::DOCUMENT_TYPE_BLUEPRINT,\n        \\Tailor\\Classes\\EditorExtension::DOCUMENT_TYPE_THEME_BLUEPRINT,\n    ], true);\n}","tryCatchPattern":"try {\n    $metadata = $this->loadTemplateMetadata($template, $documentData);\n} catch (\\SystemException $e) {\n    // type slipped through earlier validation; reject payload and log the offending type\n}","preventionTips":["Route every custom handler through assertDocumentTypePermissions() so unknown types fail early.","Keep type validation in one place (request boundary) instead of per-helper."],"tags":["tailor","editor-extension","document-type","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}