{"record":{"id":"1fdc0831adf69e24","repo":"PrefectHQ/fastmcp","slug":"expected-boolean-got-raw-r","errorCode":null,"errorMessage":"Expected boolean, got {raw!r}","messagePattern":"Expected boolean, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/cli/client.py","lineNumber":286,"sourceCode":"\n    if schema_type == \"integer\":\n        try:\n            return int(raw)\n        except ValueError:\n            raise ValueError(f\"Expected integer, got {raw!r}\") from None\n\n    if schema_type == \"number\":\n        try:\n            return float(raw)\n        except ValueError:\n            raise ValueError(f\"Expected number, got {raw!r}\") from None\n\n    if schema_type == \"boolean\":\n        if raw.lower() in (\"true\", \"1\", \"yes\"):\n            return True\n        if raw.lower() in (\"false\", \"0\", \"no\"):\n            return False\n        raise ValueError(f\"Expected boolean, got {raw!r}\")\n\n    if schema_type in (\"array\", \"object\"):\n        try:\n            return json.loads(raw)\n        except json.JSONDecodeError:\n            raise ValueError(f\"Expected JSON {schema_type}, got {raw!r}\") from None\n\n    # Default: treat as string\n    return raw\n\n\ndef parse_tool_arguments(\n    raw_args: tuple[str, ...],\n    input_json: str | None,\n    input_schema: dict[str, Any],\n) -> dict[str, Any]:\n    \"\"\"Build a tool-call argument dict from CLI inputs.\n","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/cli/client.py#L268-L304","documentation":"For boolean schema types, coerce_value accepts only true/1/yes and false/0/no (case-insensitive); anything else raises this ValueError with the raw value. Unlike the integer/number branches there is no leniency — e.g. 'on' or 'True ' with trailing whitespace fails.","triggerScenarios":"Answering a boolean elicitation prompt or passing a boolean tool argument with a string outside {true,1,yes,false,0,no}.","commonSituations":"Using 'on'/'off', 'y'/'n', or values with trailing whitespace at the CLI prompt; scripting prompts with unexpected values.","solutions":["Use one of the accepted spellings: true/false, 1/0, or yes/no","Trim whitespace from scripted input before passing it","Normalize booleans in your own code with a small parse helper before invoking the CLI"],"exampleFix":"# before\n--enabled on   # ValueError\n# after\n--enabled true","handlingStrategy":"validation","validationCode":"def is_bool_str(raw: str) -> bool:\n    return raw.strip().lower() in {'true', '1', 'yes', 'false', '0', 'no'}","typeGuard":"def coerce_bool(raw: str) -> bool | None:\n    r = raw.strip().lower()\n    if r in ('true', '1', 'yes'):\n        return True\n    if r in ('false', '0', 'no'):\n        return False\n    return None","tryCatchPattern":"try:\n    value = coerce_value(schema, raw)\nexcept ValueError as exc:\n    print(f'Invalid input: {exc}; expected true/false, 1/0, or yes/no')\n    raw = input('> ')","preventionTips":["Use only true/false, 1/0, or yes/no for boolean flags","Strip whitespace from scripted input","Normalize booleans with your own helper before CLI invocation"],"tags":["validation","cli","input-parsing","boolean"],"backgroundTag":"input-type-mismatch","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}