{"record":{"id":"24d5973eccf8056d","repo":"phalcon/cphalcon","slug":"unknown-service-type-in-parameter-on-position","errorCode":null,"errorMessage":"Unknown service type in parameter on position {}","messagePattern":"Unknown service type in parameter on position (.+?)","errorType":"exception","errorClass":"UnknownServiceType","httpStatus":null,"severity":"error","filePath":"phalcon/Di/Service/Builder.zep","lineNumber":259,"sourceCode":"\n                if fetch instanceArguments, argument[\"arguments\"] {\n                    /**\n                     * Build the instance with arguments\n                     */\n                    return container->get(name, instanceArguments);\n                }\n\n                /**\n                 * The instance parameter does not have arguments for its\n                 * constructor\n                 */\n                return container->get(name);\n\n            default:\n                /**\n                 * Unknown parameter type\n                 */\n                throw new UnknownServiceType(position);\n        }\n    }\n\n    /**\n     * Resolves an array of parameters\n     */\n    private function buildParameters(<DiInterface> container,  array arguments) -> array\n    {\n        var position, argument;\n        array buildArguments;\n\n        let buildArguments = [];\n\n        for position, argument in arguments {\n            let buildArguments[] = this->buildParameter(\n                container,\n                position,\n                argument","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Di/Service/Builder.zep#L241-L277","documentation":"Thrown by Phalcon\\Di\\Service\\Builder::buildParameter() when an argument's 'type' is not one of the three supported strings: 'service', 'parameter', 'instance'. The switch falls through to default and raises UnknownServiceType for the offending position.","triggerScenarios":"A typo in the type string: 'service ' (trailing space), 'instance ', 'paramater', 'value', 'string', 'scalar', 'class' (Phalcon 3 name), or a non-string value. Thrown at resolve time of the service whose definition contains it.","commonSituations":"Upgrading Phalcon 3 -> 4/5 and keeping 'type' => 'class'; definitions loaded from YAML/JSON where casing or whitespace differs ('Parameter' vs 'parameter'); translating definitions from another DI container's vocabulary.","solutions":["Correct the type to exactly 'service', 'parameter', or 'instance' (lowercase, no extra whitespace).","After a Phalcon 3 -> 5 upgrade, sweep all definitions for 'class' type entries and replace with 'instance' plus 'className'.","If definitions come from config files, trim/normalize type strings before registering them."],"exampleFix":"// before\n'arguments' => [\n    ['type' => 'paramater', 'value' => 10],   // typo\n],\n\n// after\n'arguments' => [\n    ['type' => 'parameter', 'value' => 10],\n],","handlingStrategy":"validation","validationCode":"const DI_ARGUMENT_TYPES = ['service', 'parameter', 'instance'];\n\nfunction normalizeDiArguments(array $arguments): array\n{\n    foreach ($arguments as $i => &$arg) {\n        $type = trim((string)($arg['type'] ?? ''));\n        if (!in_array($type, DI_ARGUMENT_TYPES, true)) {\n            throw new InvalidArgumentException(\"Argument {$i}: unknown type '{$type}'\");\n        }\n        $arg['type'] = $type;\n    }\n    return $arguments;\n}","typeGuard":"function isKnownArgumentType(mixed $arg): bool\n{\n    return is_array($arg) && in_array(trim((string)($arg['type'] ?? '')), ['service', 'parameter', 'instance'], true);\n}","tryCatchPattern":"try {\n    $service = $di->get('foo');\n} catch (\\Phalcon\\Di\\Exceptions\\UnknownServiceType $e) {\n    $logger->error('DI definition has an invalid type: ' . $e->getMessage());\n    throw $e;\n}","preventionTips":["Normalize (trim + lowercase) type strings from external config before registering definitions.","After major Phalcon upgrades, re-run your DI smoke test; the type vocabulary is version-stable but migrations from 3.x reintroduce 'class'."],"tags":["phalcon","dependency-injection","di","configuration","typo","service-container"],"backgroundTag":"di-definition-invalid","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}