{"record":{"id":"5690c6f2132d2f77","repo":"PrefectHQ/fastmcp","slug":"error-rendering-prompt-name-r","errorCode":null,"errorMessage":"Error rendering prompt {name!r}","messagePattern":"Error rendering prompt (.+?)","errorType":"exception","errorClass":"PromptError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/server/server.py","lineNumber":1792,"sourceCode":"            ) as span:\n                prompt = await self.get_prompt(name, version=version)\n                if prompt is None:\n                    raise NotFoundError(f\"Unknown prompt: {name!r}\")\n                span.set_attributes(prompt.get_span_attributes())\n                try:\n                    return await prompt._render(arguments)\n                except FastMCPError as e:\n                    logger.log(\n                        e.log_level, f\"Error rendering prompt {name!r}\", exc_info=True\n                    )\n                    raise\n                except MCPError:\n                    logger.exception(f\"Error rendering prompt {name!r}\")\n                    raise\n                except Exception as e:\n                    logger.exception(f\"Error rendering prompt {name!r}\")\n                    if self._mask_error_details:\n                        raise PromptError(f\"Error rendering prompt {name!r}\") from e\n                    raise PromptError(f\"Error rendering prompt {name!r}: {e}\") from e\n\n    def add_tool(self, tool: Tool | Callable[..., Any]) -> Tool:\n        \"\"\"Add a tool to the server.\n\n        The tool function can optionally request a Context object by adding a parameter\n        with the Context type annotation. See the @tool decorator for examples.\n\n        Args:\n            tool: The Tool instance or @tool-decorated function to register\n\n        Returns:\n            The tool instance that was added to the server.\n        \"\"\"\n        return self._local_provider.add_tool(tool)\n\n    @overload\n    def tool(","sourceCodeStart":1774,"sourceCodeEnd":1810,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/server/server.py#L1774-L1810","documentation":"This generic wrapper is raised by FastMCP.render_prompt when an unhandled exception occurs while rendering a prompt's messages/arguments. If the original error is an MCPError it is re-raised unchanged (error 540 is the log line accompanying the re-raise); otherwise the server converts it to PromptError. With mask_error_details enabled the original exception text is hidden.","triggerScenarios":"Calling server.get_prompt(name, arguments) or render_prompt() when the prompt's render function raises a non-MCP exception (bad arguments, bug in the prompt function, missing template variables).","commonSituations":"Typo in prompt argument names; prompt function references missing context; template rendering fails on None arguments; a middleware chain raises an unexpected exception type.","solutions":["Read the chained exception (__cause__) or server logs (logger.exception prints the full traceback) to find the root cause","Fix the prompt function or pass correct/complete arguments to get_prompt","Disable mask_error_details in development so the error message includes the underlying '{e}' detail","Wrap known failure modes in your prompt function and raise MCPError/PromptError directly so they pass through unmasked"],"exampleFix":"// before\nprompt = await mcp.get_prompt(\"greet\")  # missing required argument\n// after\nprompt = await mcp.get_prompt(\"greet\", {\"name\": \"Alice\"})","handlingStrategy":"try-catch","validationCode":"# ensure required args are present before rendering\nmissing = required_args - set(arguments or {})\nif missing:\n    raise ValueError(f\"missing prompt arguments: {missing}\")","typeGuard":null,"tryCatchPattern":"try:\n    prompt = await mcp.get_prompt(\"greet\", arguments)\nexcept PromptError as e:\n    logger.error(\"prompt render failed: %s\", e.__cause__)","preventionTips":["Validate prompt arguments before calling get_prompt","Keep mask_error_details off in dev to see root causes","Raise MCPError/PromptError from prompt functions for expected failures","Check server logs for the full chained traceback"],"tags":["python","prompts","server"],"backgroundTag":"prompt-render-failed","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}