octobercms/october · error · SystemException
Invalid documentMetadata
Error message
Invalid documentMetadata
What it means
getRequestMetadata() requires the request input 'documentMetadata' to be an array (it carries mtime/path/type metadata for editor commands); anything else — missing, string, null — throws SystemException 'Invalid documentMetadata'. Like the other editor-extension input guards, it signals a malformed internal request rather than an end-user mistake.
Source
Thrown at modules/cms/classes/editorextension/HasExtensionCrud.php:424
$datasource->forceDeleteModelAtIndex(0, $template);
}
/**
* getThemeDatasource returns a theme datasource object
*/
protected function getThemeDatasource()
{
return $this->getTheme()->getDatasource();
}
/**
* getRequestMetadata
*/
private function getRequestMetadata()
{
$metadata = Request::input('documentMetadata');
if (!is_array($metadata)) {
throw new SystemException('Invalid documentMetadata');
}
return $metadata;
}
/**
* getRequestExtraData
*/
private function getRequestExtraData()
{
$extraData = Request::input('extraData');
if (!is_array($extraData)) {
return [];
}
return $extraData;
}
View on GitHub (pinned to b608633a7e)
Solutions
- Send documentMetadata as an array, e.g. {mtime: 1690000000, path: 'index.htm', type: 'page'}
- Replay a request captured from the stock editor to learn the expected payload shape
- Clear cached assets after upgrading so the matching editor JS is served
Example fix
// before
$.request('onSaveDocument', { data: { documentData: {...} } }); // no metadata
// after
$.request('onSaveDocument', { data: { documentData: {...}, documentMetadata: { mtime: 1690000000, path: 'index.htm', type: 'page' } } }); Defensive patterns
Strategy: type-guard
Validate before calling
if (!is_array($metadata = request()->input('documentMetadata'))) {
$metadata = ['mtime' => null, 'path' => $path, 'type' => $type]; // or reject the request
} Type guard
function isDocumentMetadata(m) {
return m != null && typeof m === 'object' && !Array.isArray(m);
} Prevention
- Always pair documentData with a documentMetadata array in editor requests
- Type-check editor payloads before sending instead of relying on server-side SystemException
- Keep editor request builders in one helper so required fields are never omitted
When it happens
Trigger: Calling an editor-extension command that needs metadata (save/open flows) without documentMetadata in the request, or sending it as a JSON string instead of a parsed array.
Common situations: Custom clients or tests hitting editor endpoints directly; middleware altering request input; stale cached editor assets after a Winter upgrade.
Related errors
- Document data is not provided
- Component not found
- cms::lang.component.no_records
- cms::lang.component.not_found
- Component does use a default partial
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/537e24694c2837ab.
Report an issue: GitHub.