octobercms/october · error · SystemException
Unknown document type: %s
Error message
Unknown document type: %s
What it means
SystemException thrown by `EditorExtension::hasAccessToDocType($user, $documentType)` when the given document type string is not a key of `DOCUMENT_TYPE_PERMISSIONS`. Valid keys are the constants cms-page, cms-partial, cms-layout, cms-content, cms-asset, cms-lang. This is a programmer/API-contract guard: the editor permission layer refuses unknown document types before any permission lookup.
Source
Thrown at modules/cms/classes/EditorExtension.php:303
* @return array
*/
public function getSettingsForms()
{
return [
EditorExtension::DOCUMENT_TYPE_PAGE => $this->loadAndExtendCmsSettingsFields(\Cms\Classes\Page\Fields::class, 'page'),
EditorExtension::DOCUMENT_TYPE_PARTIAL => $this->loadAndExtendCmsSettingsFields(\Cms\Classes\Partial\Fields::class, 'partial'),
EditorExtension::DOCUMENT_TYPE_LAYOUT => $this->loadAndExtendCmsSettingsFields(\Cms\Classes\Layout\Fields::class, 'layout')
];
}
/**
* hasAccessToDocType
* @return array
*/
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]);
}
/**
* getTheme returns the theme object to use for the editor
*/
protected function getTheme()
{
if ($this->cachedEditTheme !== false) {
return $this->cachedEditTheme;
}
// Locate edit theme
try {
if ($editTheme = Theme::getEditTheme()) {
return $this->cachedEditTheme = $editTheme;View on GitHub (pinned to b608633a7e)
Solutions
- Use the `EditorExtension::DOCUMENT_TYPE_*` constants instead of raw strings when calling hasAccessToDocType.
- If you need a custom document type, extend/patch DOCUMENT_TYPE_PERMISSIONS in your plugin so the type maps to permission codes.
- Validate the value against `array_keys(EditorExtension::DOCUMENT_TYPE_PERMISSIONS)` before calling the API.
Example fix
// before
EditorExtension::hasAccessToDocType($user, 'cms-pagee'); // typo'd literal
// after
use Cms\Classes\EditorExtension;
$type = EditorExtension::DOCUMENT_TYPE_PAGE;
if (array_key_exists($type, EditorExtension::DOCUMENT_TYPE_PERMISSIONS)) {
EditorExtension::hasAccessToDocType($user, $type);
} Defensive patterns
Strategy: type-guard
Validate before calling
use Cms\Classes\EditorExtension;
$valid = array_key_exists($documentType, EditorExtension::DOCUMENT_TYPE_PERMISSIONS);
if (!$valid) {
abort(400, 'Unsupported document type');
} Type guard
/** @param mixed $type */
function isValidDocumentType($type): bool
{
return is_string($type)
&& array_key_exists($type, \Cms\Classes\EditorExtension::DOCUMENT_TYPE_PERMISSIONS);
} Try / catch
try {
$allowed = EditorExtension::hasAccessToDocType($user, $documentType);
} catch (System\Exception $e) {
// unknown type is a caller bug: log with the offending value and 400 out
Log::warning('Bad editor document type', ['type' => $documentType]);
return response()->json(['error' => 'Invalid document type'], 400);
} Prevention
- Always reference the EditorExtension::DOCUMENT_TYPE_* constants instead of string literals.
- Never pass a raw request parameter into permission APIs without an allow-list check.
- Declare the parameter type (string) and validate against the permissions map at your API boundary.
- Add unit tests covering every document type your plugin uses.
When it happens
Trigger: Calling `EditorExtension::hasAccessToDocType($user, 'cms-pagee')` (typo), a custom plugin passing its own document type string ('myplugin-doc') into the CMS editor extension, or forwarding an unvalidated `documentType` request parameter from an AJAX handler into this API.
Common situations: Plugin developers extending the CMS editor with new document types without registering them in the permissions map; refactors that rename a constant but leave stale string literals; unvalidated user input reaching an editor permission check.
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
- editor::lang.filesystem.error_creating_directory
- editor::lang.filesystem.error_renaming
- editor::lang.filesystem.error_deleting_file
- editor::lang.filesystem.error_deleting_dir
- editor::lang.filesystem.destination_not_found
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/ce9b1f468dc0df02.
Report an issue: GitHub.