octobercms/october · error · SystemException
Invalid documentData
Error message
Invalid documentData
What it means
getRequestDocumentData() reads `documentData` from the current request and requires an array; commands such as createTemplate depend on it. A missing, null, or string-typed value throws SystemException('Invalid documentData') before any document work starts.
Source
Thrown at modules/tailor/classes/editorextension/HasExtensionCrud.php:313
*/
private function getRequestExtraData()
{
$extraData = Request::input('extraData');
if (!is_array($extraData)) {
return [];
}
return $extraData;
}
/**
* getRequestDocumentData
*/
private function getRequestDocumentData()
{
$documentData = Request::input('documentData');
if (!is_array($documentData)) {
throw new SystemException('Invalid documentData');
}
return $documentData;
}
/**
* createTemplate
*/
private function createTemplate($documentType)
{
$class = $this->resolveTypeClassName($documentType);
$template = new $class();
return $template;
}
/**View on GitHub (pinned to b608633a7e)
Solutions
- Send documentData as an array containing the keys the command needs (at minimum type, often key/title).
- Mirror the payload structure the official editor extension client sends.
- Verify content-type and form encoding of the AJAX request (form-encoded arrays, not stringified JSON).
Defensive patterns
Strategy: validation
Validate before calling
$documentData = \Request::input('documentData');
if (!is_array($documentData) || !isset($documentData['type'])) {
throw new InvalidArgumentException('documentData array with type is required.');
} Type guard
function isValidDocumentData($data): bool
{
return is_array($data) && isset($data['type']);
} Try / catch
try {
$documentData = $this->getRequestDocumentData();
} catch (\SystemException $e) {
// malformed request — return a 422 validation error to the client instead of a 500
} Prevention
- Send arrays (form-encoded or properly parsed), never stringified JSON, for documentData.
- Mirror the core editor extension client's payload shape in custom integrations.
When it happens
Trigger: Calling an editor extension AJAX command that internally calls getRequestDocumentData() without a documentData array in the request body, or with documentData encoded as a JSON string.
Common situations: Custom clients or tests invoking tailor CRUD handlers; middleware stripping form input; payload shape changes after an October upgrade.
Related errors
- Document data is not provided
- Invalid documentMetadata
- Custom widget class [{$widgetClass}] is not set.
- The property name is not specified.
- Custom widget class [{$widgetClass}] is not set.
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/6379b5643648ed99.
Report an issue: GitHub.