{"record":{"id":"00537e9fa65d679c","repo":"phalcon/cphalcon","slug":"the-route-contains-invalid-paths","errorCode":null,"errorMessage":"The route contains invalid paths","messagePattern":"The route contains invalid paths","errorType":"exception","errorClass":"Phalcon\\Mvc\\Router\\Exceptions\\InvalidRoutePaths","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/Router/Route.zep","lineNumber":563,"sourceCode":"                        let routePaths[\"namespace\"] = namespaceName;\n                    }\n                } else {\n                    let realClassName = controllerName;\n                }\n\n                let routePaths[\"controller\"] = realClassName;\n            }\n\n            // Process action name\n            if actionName !== null {\n                let routePaths[\"action\"] = actionName;\n            }\n        } else {\n            let routePaths = paths;\n        }\n\n        if unlikely typeof routePaths !== \"array\" {\n            throw new InvalidRoutePaths();\n        }\n\n        return routePaths;\n    }\n\n    /**\n     * Allows to set a callback to handle the request directly in the route\n     *\n     *```php\n     * $router->add(\n     *     \"/help\",\n     *     []\n     * )->match(\n     *     function () {\n     *         return $this->getResponse()->redirect(\"https://support.google.com/\", true);\n     *     }\n     * );\n     *```","sourceCodeStart":545,"sourceCodeEnd":581,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/Router/Route.zep#L545-L581","documentation":"Route::getRoutePaths() is the normalizer behind route path handling: it accepts null (empty paths), a string in 'Controller::action' or 'Module::Controller::action' short syntax (parsed into an array), or an already-built array. Anything else falls through the else-branch, stays non-array, and throws InvalidRoutePaths. This guards every route-creation entry point (add/addGet/addPost/... and group adds) at definition time.","triggerScenarios":"$router->add('/x', 123); $router->add('/x', false); passing a stdClass/Config object as paths; passing null is fine, but a resource or float is not; feeding an object because config was decoded without the associative flag.","commonSituations":"Variables interpolated from config where a missing key defaulted to a scalar; booleans used as flags accidentally passed as the second argument; JSON-decoded route paths arriving as stdClass instead of array.","solutions":["Pass an associative array: $router->add('/x', ['controller' => 'index', 'action' => 'hello']);","Or the short string: $router->add('/x', 'Index::hello');","Decode config arrays with json_decode(..., true) and cast nested path objects to arrays before registration"],"exampleFix":"// before\n$router->add('/hello', $config->helloPaths); // value is stdClass/\"Index::hello\" object or scalar\n\n// after\n$paths = is_object($config->helloPaths)\n    ? $config->helloPaths->toArray()\n    : $config->helloPaths;\n$router->add('/hello', $paths); // array or 'Index::hello' string","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function isAcceptablePaths(mixed $paths): bool\n{\n    return $paths === null\n        || is_array($paths)\n        || (is_string($paths) && str_contains($paths, '::'));\n}","tryCatchPattern":"try {\n    $router->add($pattern, $paths);\n} catch (\\Phalcon\\Mvc\\Router\\Exceptions\\InvalidRoutePaths $e) {\n    $logger->error(\n        'Invalid paths for pattern ' . $pattern . ': ' . get_debug_type($paths)\n    );\n    throw $e;\n}","preventionTips":["Standardize on arrays (or the 'Controller::action' short string) for every add() call","json_decode route configs with associative=true so path objects arrive as arrays","Cast or reject stdClass/scalar path values in your config loader before registration"],"tags":["phalcon","router","route-paths","validation","route-definition"],"backgroundTag":"invalid-route-paths","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}