{"record":{"id":"6da1b8d19ae979e7","repo":"crewAIInc/crewAI","slug":"invalid-inputs-json-exc","errorCode":null,"errorMessage":"Invalid --inputs JSON: {exc}","messagePattern":"Invalid --inputs JSON: (.+?)","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"lib/cli/src/crewai_cli/input_prompt.py","lineNumber":33,"sourceCode":"import json\nimport sys\nfrom typing import Any\n\nimport click\n\nfrom crewai_cli.utils import enable_prompt_line_editing, is_dmn_mode_enabled\n\n\ndef parse_inputs_json(inputs: str | None) -> dict[str, Any] | None:\n    \"\"\"Parse a ``--inputs`` JSON object, exiting with a pointed error if invalid.\"\"\"\n    if inputs is None:\n        return None\n\n    try:\n        parsed = json.loads(inputs)\n    except json.JSONDecodeError as exc:\n        click.echo(f\"Invalid --inputs JSON: {exc}\", err=True)\n        raise SystemExit(1) from exc\n\n    if not isinstance(parsed, dict):\n        click.echo(\"Invalid --inputs JSON: expected an object.\", err=True)\n        raise SystemExit(1)\n\n    return parsed\n\n\ndef closest_name(key: str, candidates: Iterable[str]) -> str | None:\n    \"\"\"Nearest candidate name to a likely typo, if one is close enough.\"\"\"\n    matches = difflib.get_close_matches(key, list(candidates), n=1, cutoff=0.7)\n    return matches[0] if matches else None\n\n\ndef is_interactive() -> bool:\n    \"\"\"Prompt only in an interactive terminal, never in non-interactive mode.\"\"\"\n    return not is_dmn_mode_enabled() and sys.stdin.isatty()\n","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/cli/src/crewai_cli/input_prompt.py#L15-L51","documentation":"Emitted by parse_inputs_json when the --inputs CLI option contains text that json.loads cannot parse (JSONDecodeError), after which the CLI exits with code 1. The message echoes the decoder's precise reason (line/column, e.g. 'Expecting value: line 1 column 1'). This guards the structured inputs passed to crew/flow run commands before any execution starts.","triggerScenarios":"Passing `crewai run --inputs \"{'topic': 'x'}\"` (single quotes = invalid JSON), an unterminated string, trailing commas, smart quotes pasted from a doc, or a shell that mangles the quoting so an empty/partial string reaches the parser.","commonSituations":"Single-quoted Python-style dicts pasted into shell, copy-paste from editors that substitute curly quotes, forgetting to close a quote so shell splits the JSON, or Windows cmd quoting differences around double quotes.","solutions":["Use strict double-quoted JSON: `--inputs \"{\\\"topic\\\": \\\"AI\\\"}\"` or single-quote the whole arg on POSIX: `--inputs '{\"topic\": \"AI\"}'`","Validate first: `echo '<your json>' | python -m json.tool` to localize the syntax error (the message already gives line/column)","Replace smart/curly quotes with straight quotes","On Windows, escape inner double quotes or pass via a file if the CLI supports it"],"exampleFix":"# before\ncrewai run --inputs \"{'topic': 'AI agents'}\"\n# after\ncrewai run --inputs '{\"topic\": \"AI agents\"}'","handlingStrategy":"validation","validationCode":"import json\n\ndef inputs_json_valid(s: str | None) -> bool:\n    if s is None:\n        return True\n    try:\n        return isinstance(json.loads(s), dict)\n    except json.JSONDecodeError:\n        return False","typeGuard":"def parse_inputs(s: str) -> dict | None:\n    import json\n    try:\n        v = json.loads(s)\n    except json.JSONDecodeError:\n        return None\n    return v if isinstance(v, dict) else None","tryCatchPattern":"try:\n    parse_inputs_json(raw)\nexcept SystemExit as e:\n    if e.code == 1:\n        # invalid --inputs JSON; re-prompt or show expected shape\n        ...","preventionTips":["Always single-quote the JSON object on POSIX shells","Validate with python -m json.tool before pasting","Use straight double quotes inside the JSON; watch for editor smart quotes"],"tags":["cli","json","validation","inputs"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}