{"record":{"id":"9ece72e08e24653f","repo":"the-benchmarker/web-frameworks","slug":"parameter-definition-getmeta-name-of-controller-action","errorCode":null,"errorMessage":"Parameter '{$definition->getMeta('name')}' of {$controller}::{$action} should not be null","messagePattern":"Parameter '(.+?)' of (.+?)::(.+?) should not be null","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"php/hyperf/app/Kernel/FastServer.php","lineNumber":143,"sourceCode":"     * Parse the parameters of method definitions, and then bind the specified arguments or\n     * get the value from DI container, combine to a argument array that should be injected\n     * and return the array.\n     */\n    protected function parseParameters(string $controller, string $action, array $arguments): array\n    {\n        $injections = [];\n        $definitions = $this->methodDefinitionCollector->getParameters($controller, $action);\n        foreach ($definitions ?? [] as $pos => $definition) {\n            $value = $arguments[$pos] ?? $arguments[$definition->getMeta('name')] ?? null;\n            if ($value === null) {\n                if ($definition->getMeta('defaultValueAvailable')) {\n                    $injections[] = $definition->getMeta('defaultValue');\n                } elseif ($definition->allowsNull()) {\n                    $injections[] = null;\n                } elseif ($this->container->has($definition->getName())) {\n                    $injections[] = $this->container->get($definition->getName());\n                } else {\n                    throw new \\InvalidArgumentException(\"Parameter '{$definition->getMeta('name')}' \"\n                        . \"of {$controller}::{$action} should not be null\");\n                }\n            } else {\n                $injections[] = $this->normalizer->denormalize($value, $definition->getName());\n            }\n        }\n\n        return $injections;\n    }\n}\n","sourceCodeStart":125,"sourceCodeEnd":154,"githubUrl":"https://github.com/the-benchmarker/web-frameworks/blob/3795a31d724e41cdb87b6e0d3ac941b7bfac3ea2/php/hyperf/app/Kernel/FastServer.php#L125-L154","documentation":"Hyperf's FastServer route-parameter parser (parseParameters) builds the argument list for a controller action. When a required request parameter has no value, no default, does not allow null, and its name does not resolve to a container entry, it throws this InvalidArgumentException because the action cannot be invoked with a null it declared mandatory.","triggerScenarios":"A client calls an HTTP route whose action signature declares a parameter with a definition that (a) received no value in the request, (b) has no defaultValue in its metadata, (c) does not allowNull(), and (d) is not a container-managed service — reached via handleFound -> parseParameters.","commonSituations":"Client omits a required query/body parameter; frontend sends a different parameter name than the action expects (typo or renamed field); middleware stripped the value; a new required parameter was added to the action while old clients still call the endpoint without it.","solutions":["Have the client send the missing parameter, or make it optional by allowing null or adding a defaultValue in the parameter definition","Verify the request actually contains the parameter under the exact name the action expects (check typos and content-type handling)","Change the action signature so the parameter is nullable or has a documented default when it is legitimately optional","Return a clean 400 validation response instead of a 500 by validating input before dispatch or mapping this exception in the exception handler"],"exampleFix":"// before\npublic function show(string $id) { ... } // client omits id\n\n// after\npublic function show(?string $id = null) {\n    if ($id === null) {\n        throw new HyperfValidationValidationException('id is required');\n    }\n    ...\n}","handlingStrategy":"validation","validationCode":"// before dispatching, ensure required params are present\nconst REQUIRED: array<string, string> = ['id' => 'query', 'name' => 'body'];\nforeach (REQUIRED as $name => $where) {\n    $value = $where === 'query' ? $request->getQueryParam($name) : $request->getParsedBody()[$name] ?? null;\n    if ($value === null || $value === '') {\n        throw new \\Hyperf\\HttpMessage\\Exception\\BadRequestHttpException(\"Missing required parameter: {$name}\");\n    }\n}","typeGuard":"function hasParam(?string $value): bool\n{\n    return $value !== null && $value !== '';\n}","tryCatchPattern":"try {\n    $response = $this->handleFound($route, $request);\n} catch (\\InvalidArgumentException $e) {\n    if (str_contains($e->getMessage(), 'should not be null')) {\n        return $responseFactory->createResponse(400)->withJson(['error' => $e->getMessage()]);\n    }\n    throw $e;\n}","preventionTips":["Declare defaults or nullable types for parameters that are legitimately optional","Keep action parameter names in sync with what the frontend actually sends (contract tests help)","Add an exception handler that maps this InvalidArgumentException to a 400 instead of a 500","Document each route's required parameters and lint against client SDK definitions"],"tags":["php","hyperf","request-parameter","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"3795a31d724e41cdb87b6e0d3ac941b7bfac3ea2","analyzedAt":"2026-09-15T02:39:22.409Z","contentChangedAt":"2026-09-15T02:39:22.409Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}