{"record":{"id":"1bab7e132de63a7f","repo":"phalcon/cphalcon","slug":"service-value-is-required-in-parameter-on-positi","errorCode":null,"errorMessage":"Service 'value' is required in parameter on position {}","messagePattern":"Service 'value' is required in parameter on position (.+?)","errorType":"exception","errorClass":"MissingParameterKey","httpStatus":null,"severity":"error","filePath":"phalcon/Di/Service/Builder.zep","lineNumber":229,"sourceCode":"\n        switch type {\n            /**\n             * If the argument type is 'service', we obtain the service from the\n             * DI\n             */\n            case \"service\":\n                if unlikely !fetch name, argument[\"name\"] {\n                    throw new MissingParameterKey(\"name\", position);\n                }\n\n                return container->get(name);\n\n            /**\n             * If the argument type is 'parameter', we assign the value as it is\n             */\n            case \"parameter\":\n                if unlikely !fetch value, argument[\"value\"] {\n                    throw new MissingParameterKey(\"value\", position);\n                }\n\n                return value;\n\n            /**\n             * If the argument type is 'instance', we assign the value as it is\n             */\n            case \"instance\":\n                if unlikely !fetch name, argument[\"className\"] {\n                    throw new MissingParameterKey(\"className\", position);\n                }\n\n                if fetch instanceArguments, argument[\"arguments\"] {\n                    /**\n                     * Build the instance with arguments\n                     */\n                    return container->get(name, instanceArguments);\n                }","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Di/Service/Builder.zep#L211-L247","documentation":"Thrown by Phalcon\\Di\\Service\\Builder::buildParameter() when an argument is declared with 'type' => 'parameter' but has no 'value' key. The 'parameter' type injects a literal value as-is; the 'value' key carries that literal. Without it the builder has nothing to pass to the constructor.","triggerScenarios":"An argument entry like ['type' => 'parameter'] (or 'value' misspelled as 'val', 'default', 'data') inside an array service definition, surfacing when the service is resolved. Message reads: \"Service 'value' is required in parameter on position N\".","commonSituations":"Copy-pasting a 'service' argument and changing the type but forgetting the companion key, renaming keys, or passing nested arrays that were flattened somewhere (config loading, environment-specific overrides) so 'value' got lost.","solutions":["Add the literal: ['type' => 'parameter', 'value' => 42].","Check the position reported in the message (0-based) against your 'arguments' array to find the entry missing 'value'.","If values come from config, assert the config key exists before building the definition."],"exampleFix":"// before\n$di->set('cache', [\n    'className' => \\App\\Cache::class,\n    'arguments' => [\n        ['type' => 'parameter'],            // missing value\n    ],\n]);\n\n// after\n$di->set('cache', [\n    'className' => \\App\\Cache::class,\n    'arguments' => [\n        ['type' => 'parameter', 'value' => 3600],\n    ],\n]);","handlingStrategy":"validation","validationCode":"function assertParameterHasValue(array $arg, int $position): void\n{\n    if (($arg['type'] ?? null) === 'parameter' && !array_key_exists('value', $arg)) {\n        throw new InvalidArgumentException(\"Argument {$position}: type 'parameter' requires 'value'\");\n    }\n}","typeGuard":"function isParameterArgumentWithValue(mixed $arg): bool\n{\n    return is_array($arg)\n        && ($arg['type'] ?? null) === 'parameter'\n        && array_key_exists('value', $arg); // value may legitimately be 0/false/null\n}","tryCatchPattern":"try {\n    $di->get('mailer');\n} catch (\\Phalcon\\Di\\Exceptions\\MissingParameterKey $e) {\n    if (str_contains($e->getMessage(), \"'value'\")) {\n        // literal argument missing its value - definition bug, fix the config\n    }\n    throw $e;\n}","preventionTips":["Use array_key_exists rather than isset when auditing definitions - a legitimate value of null or 0 must not be flagged.","When definitions come from YAML/JSON, run the validator right after loading, before registration."],"tags":["phalcon","dependency-injection","di","configuration","service-container"],"backgroundTag":"di-definition-invalid","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}