phalcon/cphalcon · error · Phalcon\Mvc\Model\Exceptions\UnknownEagerRelation

Model '{modelName}' does not define a relation with alias '{

Error message

Model '{modelName}' does not define a relation with alias '{alias}'

What it means

Error "Model '{modelName}' does not define a relation with alias '{alias}'" thrown in phalcon/cphalcon.

Source

Thrown at phalcon/Mvc/Model/Eager/Loader.zep:163

     *
     * @param array $parents attribute-keyed row arrays at the root, or
     *                       ModelInterface / Row instances below it
     */
    protected function buildMap(
        array parents,
        string modelName,
        array tree
    ) -> array {
        var alias, node, relation;
        array map;

        let map = [];

        for alias, node in tree {
            let relation = this->manager->getRelationByAlias(modelName, alias);

            if unlikely typeof relation !== "object" {
                throw new UnknownEagerRelation(modelName, alias);
            }

            let map[strtolower(alias)] = this->buildNode(
                relation,
                alias,
                parents,
                node
            );
        }

        return map;
    }

    /**
     * Builds a single map node: one query, indexed by the referenced field.
     */
    protected function buildNode(
        <RelationInterface> relation,

View on GitHub (pinned to b7419de9cd)

When it happens

Trigger: Thrown at phalcon/Mvc/Model/Eager/Loader.zep:163 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21). Data as JSON: /api/errors/59916ec7b53bbebb. Report an issue: GitHub.