{"record":{"id":"a3d1db1ebea7b295","repo":"PrefectHQ/fastmcp","slug":"missing-required-arguments-missing","errorCode":null,"errorMessage":"Missing required arguments: {missing}","messagePattern":"Missing required arguments: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/prompts/function_prompt.py","lineNumber":324,"sourceCode":"                        ) from e\n            else:\n                # Parameter not in function signature, pass as-is\n                converted_kwargs[param_name] = param_value\n\n        return converted_kwargs\n\n    async def render(\n        self,\n        arguments: dict[str, Any] | None = None,\n    ) -> PromptResult:\n        \"\"\"Render the prompt with arguments.\"\"\"\n        # Validate required arguments\n        if self.arguments:\n            required = {arg.name for arg in self.arguments if arg.required}\n            provided = set(arguments or {})\n            missing = required - provided\n            if missing:\n                raise ValueError(f\"Missing required arguments: {missing}\")\n\n        try:\n            # Prepare arguments\n            kwargs = arguments.copy() if arguments else {}\n\n            # Convert string arguments to expected types BEFORE validation\n            kwargs = self._convert_string_arguments(kwargs)\n\n            # Filter out arguments that aren't in the function signature\n            # This is important for security: dependencies should not be overridable\n            # from external callers. self.fn is wrapped by without_injected_parameters,\n            # so we only accept arguments that are in the wrapped function's signature.\n            sig = inspect.signature(self.fn)\n            valid_params = set(sig.parameters.keys())\n            kwargs = {k: v for k, v in kwargs.items() if k in valid_params}\n\n            # Use type adapter to validate arguments and handle Field() defaults\n            # This matches the behavior of tools in function_tool","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/prompts/function_prompt.py#L306-L342","documentation":"A Prompt raises ValueError during render() because one or more arguments declared as required in the prompt's arguments spec were not supplied in the arguments dict. FastMCP validates required arguments up-front so the underlying render function never runs with an incomplete signature. The message lists the exact missing argument names in a set.","triggerScenarios":"Calling prompt.render(arguments) (or via a client prompts.get_prompt) while omitting a declared-required PromptArgument, e.g. arguments spec has PromptArgument(name='code', required=True) but render({'other': 'x'}) is called, or render() is called with arguments=None.","commonSituations":"Client code omits optional-looking params; a prompt was refactored to add a new required argument and existing callers weren't updated; LLM clients send partial arguments from a template; passing {'code': None} keeps the key in the provided set so this check passes but the fn may fail later.","solutions":["Add the missing argument(s) named in the error to the arguments dict passed to render()","If the argument should be optional, change its PromptArgument to required=False in the prompt's arguments spec","If calling from a client, fetch the prompt's argument metadata (list_prompts / prompt.arguments) and construct the full arguments dict","Guard the call site by diffing required names against your dict keys before rendering"],"exampleFix":"// before\nawait prompt.render({})\n// after\nawait prompt.render({'code': 'def foo(): pass', 'language': 'python'})","handlingStrategy":"validation","validationCode":"required = {a.name for a in prompt.arguments if a.required}\nmissing = required - set(arguments or {})\nif missing:\n    raise ValueError(f'cannot render prompt, missing: {missing}')\nresult = prompt.render(arguments)","typeGuard":null,"tryCatchPattern":"try:\n    result = prompt.render(arguments)\nexcept ValueError as e:\n    logger.warning('prompt arguments rejected: %s', e)\n    result = None","preventionTips":["Inspect prompt.arguments at startup and build your call payloads from it","Treat new required prompt arguments as a breaking change and update all call sites","Prefer fetching prompt metadata from the server before calling get_prompt"],"tags":["prompts","validation","arguments"],"backgroundTag":"missing-required-argument","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}