{"record":{"id":"517b284d832395db","repo":"octobercms/october","slug":"unable-to-find-a-registered-partial-with-code","errorCode":null,"errorMessage":"Unable to find a registered partial with code: ","messagePattern":"Unable to find a registered partial with code: ","errorType":"exception","errorClass":"October\\Rain\\Exception\\ApplicationException","httpStatus":null,"severity":"error","filePath":"modules/system/models/MailPartial.php","lineNumber":114,"sourceCode":"            $partial->is_custom = 0;\n            $partial->fillFromView($path);\n            $partial->save();\n        }\n    }\n\n    /**\n     * fillFromCode\n     */\n    public function fillFromCode($code = null)\n    {\n        $definitions = MailManager::instance()->listRegisteredPartials();\n\n        if ($code === null) {\n            $code = $this->code;\n        }\n\n        if (!$definition = array_get($definitions, $code)) {\n            throw new ApplicationException('Unable to find a registered partial with code: '.$code);\n        }\n\n        $this->fillFromView($definition);\n    }\n\n    /**\n     * fillFromView\n     */\n    public function fillFromView($path)\n    {\n        $sections = self::getTemplateSections($path);\n\n        $this->name = array_get($sections, 'settings.name', '???');\n        $this->content_html =  array_get($sections, 'html');\n        $this->content_text = array_get($sections, 'text');\n    }\n\n    /**","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/system/models/MailPartial.php#L96-L132","documentation":"MailPartial::fillFromCode($code) is the partial counterpart of MailLayout's: it looks the code up in MailManager::listRegisteredPartials() (populated from plugins' registerMailPartials(), code => view path) and throws 'Unable to find a registered partial with code: <code>' when the code is not registered, since fillFromView() has no source template.","triggerScenarios":"A mail_partials row whose code no plugin registers: the providing plugin uninstalled/disabled while its row remains, the code edited, or the registration renamed in a plugin update.","commonSituations":"Plugin removal leaving orphaned partial rows; mail partial sync after renaming registration keys; DB edits to the code column.","solutions":["Restore the registration in the providing plugin's registerMailPartials() using the same code","Or delete the orphaned partial row from the backend mail partials list / database","Keep registration codes stable across plugin updates; when renaming, migrate the seeded rows too"],"exampleFix":"// before: a partial row has code 'acme.button' but nothing registers it\n\n// after, in the plugin's Plugin.php\npublic function registerMailPartials()\n{\n    return [\n        'acme.button' => 'acme.plugin::mail.partials.button',\n    ];\n}","handlingStrategy":"validation","validationCode":"$registered = \\System\\Classes\\MailManager::instance()->listRegisteredPartials();\nif (!array_key_exists($code, $registered)) {\n    // skip fillFromCode; the code has no registered view source\n}","typeGuard":null,"tryCatchPattern":"try { $partial->fillFromCode($code); } catch (\\ApplicationException $ex) { /* re-register the partial or drop the orphaned row */ }","preventionTips":["Keep registerMailPartials() codes stable; migrate seeded rows when renaming","Remove orphaned mail partial rows when their plugin is uninstalled","Check listRegisteredPartials() before programmatically filling partials from codes"],"tags":["mail","partial","registration","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}