octobercms/october · error · SystemException

Unknown document type: %s

Error message

Unknown document type: %s

What it means

EditorExtension::hasAccessToDocType() maps a document type to required backend permissions via the DOCUMENT_TYPE_PERMISSIONS map, which only registers 'tailor-blueprint' and 'tailor-theme-blueprint'. Any other string (or null) is rejected with sprintf('Unknown document type: %s') before permission checks even run.

Source

Thrown at modules/tailor/classes/EditorExtension.php:148

    /**
     * getNewDocumentsData
     */
    public function getNewDocumentsData()
    {
        return [
            EditorExtension::DOCUMENT_TYPE_BLUEPRINT => $this->getTailorBlueprintNewDocumentData(),
            EditorExtension::DOCUMENT_TYPE_THEME_BLUEPRINT => $this->getTailorThemeBlueprintNewDocumentData()
        ];
    }

    /**
     * hasAccessToDocType
     */
    public static function hasAccessToDocType($user, $documentType)
    {
        if (!array_key_exists($documentType, EditorExtension::DOCUMENT_TYPE_PERMISSIONS)) {
            throw new SystemException(sprintf('Unknown document type: %s', $documentType));
        }

        return $user->hasAnyAccess(EditorExtension::DOCUMENT_TYPE_PERMISSIONS[$documentType]);
    }

    /**
     * getCustomData returns custom state data required for the extension client-side controller
     */
    public function getCustomData(): array
    {
        return [
            'blueprintTemplates' => [
                'entry' => $this->getBlueprintTemplate('entry'),
                'single' => $this->getBlueprintTemplate('single'),
                'stream' => $this->getBlueprintTemplate('stream'),
                'structure' => $this->getBlueprintTemplate('structure'),
                'mixin' => $this->getBlueprintTemplate('mixin'),
                'global' => $this->getBlueprintTemplate('global'),

View on GitHub (pinned to b608633a7e)

Solutions

  1. Pass EditorExtension::DOCUMENT_TYPE_BLUEPRINT ('tailor-blueprint') or EditorExtension::DOCUMENT_TYPE_THEME_BLUEPRINT ('tailor-theme-blueprint') — use the constants, not literals.
  2. When handling client input, validate the type against array_keys(EditorExtension::DOCUMENT_TYPE_PERMISSIONS) before calling hasAccessToDocType().

Example fix

// before
EditorExtension::hasAccessToDocType($user, 'blueprint');

// after
EditorExtension::hasAccessToDocType($user, EditorExtension::DOCUMENT_TYPE_BLUEPRINT);
Defensive patterns

Strategy: type-guard

Validate before calling

$known = array_keys(\Tailor\Classes\EditorExtension::DOCUMENT_TYPE_PERMISSIONS);
if (!in_array($documentType, $known, true)) {
    throw new InvalidArgumentException('Unknown document type: ' . $documentType);
}

Type guard

function isKnownTailorDocumentType($type): bool
{
    return is_string($type) && array_key_exists(
        $type,
        \Tailor\Classes\EditorExtension::DOCUMENT_TYPE_PERMISSIONS
    );
}

Try / catch

try {
    EditorExtension::hasAccessToDocType($user, $documentType);
} catch (\SystemException $e) {
    // reject/log the malformed document type before it reaches permission logic
}

Prevention

When it happens

Trigger: Calling EditorExtension::hasAccessToDocType($user, $type) with a hand-built string like 'blueprint' or 'tailor_blueprint' instead of the EditorExtension::DOCUMENT_TYPE_* constants; the editor extension client sending an unexpected `type` value in documentData.

Common situations: Custom code integrating with the editor extension API; typo'd type literals; payloads from older versions after a CMS upgrade; tests calling the method with arbitrary strings.

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


AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21). Data as JSON: /api/errors/f461580303aef666. Report an issue: GitHub.