{"record":{"id":"537e24694c2837ab","repo":"octobercms/october","slug":"invalid-documentmetadata","errorCode":null,"errorMessage":"Invalid documentMetadata","messagePattern":"Invalid documentMetadata","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/cms/classes/editorextension/HasExtensionCrud.php","lineNumber":424,"sourceCode":"        $datasource->forceDeleteModelAtIndex(0, $template);\n    }\n\n    /**\n     * getThemeDatasource returns a theme datasource object\n     */\n    protected function getThemeDatasource()\n    {\n        return $this->getTheme()->getDatasource();\n    }\n\n    /**\n     * getRequestMetadata\n     */\n    private function getRequestMetadata()\n    {\n        $metadata = Request::input('documentMetadata');\n        if (!is_array($metadata)) {\n            throw new SystemException('Invalid documentMetadata');\n        }\n\n        return $metadata;\n    }\n\n    /**\n     * getRequestExtraData\n     */\n    private function getRequestExtraData()\n    {\n        $extraData = Request::input('extraData');\n        if (!is_array($extraData)) {\n            return [];\n        }\n\n        return $extraData;\n    }\n","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/cms/classes/editorextension/HasExtensionCrud.php#L406-L442","documentation":"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.","triggerScenarios":"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.","commonSituations":"Custom clients or tests hitting editor endpoints directly; middleware altering request input; stale cached editor assets after a Winter upgrade.","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"],"exampleFix":"// before\n$.request('onSaveDocument', { data: { documentData: {...} } }); // no metadata\n\n// after\n$.request('onSaveDocument', { data: { documentData: {...}, documentMetadata: { mtime: 1690000000, path: 'index.htm', type: 'page' } } });","handlingStrategy":"type-guard","validationCode":"if (!is_array($metadata = request()->input('documentMetadata'))) {\n    $metadata = ['mtime' => null, 'path' => $path, 'type' => $type]; // or reject the request\n}","typeGuard":"function isDocumentMetadata(m) {\n  return m != null && typeof m === 'object' && !Array.isArray(m);\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["editor","api-contract","request-payload","cms","backend"],"backgroundTag":"missing-request-payload","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}