octobercms/october · error · October\Rain\Exception\ApplicationException

Unable to find a registered partial with code:

Error message

Unable to find a registered partial with code: 

What it means

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.

Source

Thrown at modules/system/models/MailPartial.php:114

            $partial->is_custom = 0;
            $partial->fillFromView($path);
            $partial->save();
        }
    }

    /**
     * fillFromCode
     */
    public function fillFromCode($code = null)
    {
        $definitions = MailManager::instance()->listRegisteredPartials();

        if ($code === null) {
            $code = $this->code;
        }

        if (!$definition = array_get($definitions, $code)) {
            throw new ApplicationException('Unable to find a registered partial with code: '.$code);
        }

        $this->fillFromView($definition);
    }

    /**
     * fillFromView
     */
    public function fillFromView($path)
    {
        $sections = self::getTemplateSections($path);

        $this->name = array_get($sections, 'settings.name', '???');
        $this->content_html =  array_get($sections, 'html');
        $this->content_text = array_get($sections, 'text');
    }

    /**

View on GitHub (pinned to b608633a7e)

Solutions

  1. Restore the registration in the providing plugin's registerMailPartials() using the same code
  2. Or delete the orphaned partial row from the backend mail partials list / database
  3. Keep registration codes stable across plugin updates; when renaming, migrate the seeded rows too

Example fix

// before: a partial row has code 'acme.button' but nothing registers it

// after, in the plugin's Plugin.php
public function registerMailPartials()
{
    return [
        'acme.button' => 'acme.plugin::mail.partials.button',
    ];
}
Defensive patterns

Strategy: validation

Validate before calling

$registered = \System\Classes\MailManager::instance()->listRegisteredPartials();
if (!array_key_exists($code, $registered)) {
    // skip fillFromCode; the code has no registered view source
}

Try / catch

try { $partial->fillFromCode($code); } catch (\ApplicationException $ex) { /* re-register the partial or drop the orphaned row */ }

Prevention

When it happens

Trigger: 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.

Common situations: Plugin removal leaving orphaned partial rows; mail partial sync after renaming registration keys; DB edits to the code column.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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