{"record":{"id":"94f4bb734dfb1668","repo":"PrefectHQ/fastmcp","slug":"cannot-specify-both-hide-true-and-required-true","errorCode":null,"errorMessage":"Cannot specify both 'hide=True' and 'required=True'. Hidden parameters cannot be required since clients cannot provide them.","messagePattern":"Cannot specify both 'hide=True' and 'required=True'\\. Hidden parameters cannot be required since clients cannot provide them\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/tools/tool_transform.py","lineNumber":207,"sourceCode":"                \"Cannot specify both 'default' and 'default_factory' in ArgTransform. \"\n                \"Use either 'default' for a static value or 'default_factory' for a callable.\"\n            )\n\n        if has_factory and not self.hide:\n            raise ValueError(\n                \"default_factory can only be used with hide=True. \"\n                \"Visible parameters must use static 'default' values since JSON schema \"\n                \"cannot represent dynamic factories.\"\n            )\n\n        if self.required is True and (has_default or has_factory):\n            raise ValueError(\n                \"Cannot specify 'required=True' with 'default' or 'default_factory'. \"\n                \"Required parameters cannot have defaults.\"\n            )\n\n        if self.hide and self.required is True:\n            raise ValueError(\n                \"Cannot specify both 'hide=True' and 'required=True'. \"\n                \"Hidden parameters cannot be required since clients cannot provide them.\"\n            )\n\n        if self.required is False:\n            raise ValueError(\n                \"Cannot specify 'required=False'. Set a default value instead.\"\n            )\n\n\nclass ArgTransformConfig(FastMCPBaseModel):\n    \"\"\"A model for requesting a single argument transform.\"\"\"\n\n    name: str | None = Field(default=None, description=\"The new name for the argument.\")\n    description: str | None = Field(\n        default=None, description=\"The new description for the argument.\"\n    )\n    default: str | int | float | bool | None = Field(","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/tools/tool_transform.py#L189-L225","documentation":"ArgTransform rejects hide=True together with required=True: a hidden parameter is removed from the transformed schema, so clients can never provide it, making a 'required hidden' parameter impossible. __post_init__ raises ValueError.","triggerScenarios":"ArgTransform(hide=True, required=True).","commonSituations":"Hiding an internal/credential parameter that the parent tool marks as required, without realizing the transform must supply a default instead.","solutions":["Remove required=True and provide default= or default_factory= along with hide=True.","If the client must supply the value, don't hide it (remove hide=True).","Supply the value in the replacement function body instead of declaring it required."],"exampleFix":"// before\nArgTransform(name=\"secret\", hide=True, required=True)\n\n// after\nArgTransform(name=\"secret\", hide=True, default=\"from-env\")","handlingStrategy":"validation","validationCode":"def check_hidden_required(t: ArgTransform) -> None:\n    if t.hide and t.required is True:\n        raise ValueError(\"Hidden params cannot be required\")","typeGuard":null,"tryCatchPattern":"try:\n    t = ArgTransform(hide=True, required=True)\nexcept ValueError:\n    t = ArgTransform(hide=True, default=\"injected-value\")","preventionTips":["Hidden params always need a default or default_factory — plan for it when hiding.","If clients must supply the value, it cannot be hidden.","Audit hide=True transforms against the parent tool's required params."],"tags":["python","tool-transform","validation"],"backgroundTag":"mutually-exclusive-parameters","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}