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

  1. Send documentData as an array containing the keys the command needs (at minimum type, often key/title).
  2. Mirror the payload structure the official editor extension client sends.
  3. 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

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


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