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

Invalid eager loading path

Error message

Invalid eager loading path '{path}'

What it means

Thrown by PathTree::parse() when an entry in the eager-loading spec is used as a path but is not a string (e.g. an integer key was interpreted as a path, or an invalid value type was passed). The message shows the offending value or its class name.

Solutions

  1. Pass eager paths as strings, e.g. ['robots' => ['options' => [...]]] or a plain list of strings
  2. Use dot notation for nested paths ('robots.parts') instead of nested arrays without string keys
  3. Ensure the with()/eager() argument is a well-formed array of string paths or key => options maps
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at phalcon/Mvc/Model/Eager/PathTree.zep:55 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/6ff2e27d298efe58. Report an issue: GitHub.

Appendix: source

Thrown at phalcon/Mvc/Model/Eager/PathTree.zep:55

     */
    public static function parse(array spec) -> array
    {
        var key, options, path, segments, value;
        array tree;

        let tree = [];

        for key, value in spec {
            if typeof key === "string" {
                let path    = key,
                    options = value;
            } else {
                let path    = value,
                    options = [];
            }

            if unlikely typeof path !== "string" {
                throw new InvalidEagerPath(
                    typeof path === "object" ? get_class(path) : (string) path
                );
            }

            if unlikely typeof options !== "array" {
                throw new InvalidEagerPath(path);
            }

            self::assertOptions(options);

            let segments = explode(".", path);

            if unlikely count(segments) > self::MAX_DEPTH {
                throw new InvalidEagerPath(path);
            }

            let tree = self::insert(tree, path, segments, 0, options);
        }

View on GitHub (pinned to b7419de9cd)