{"record":{"id":"37fd6b32b2b80e08","repo":"crewAIInc/crewAI","slug":"invalid-json-payload-provided-as-argument","errorCode":null,"errorMessage":"Invalid JSON payload provided as argument","messagePattern":"Invalid JSON payload provided as argument","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"lib/cli/src/crewai_cli/templates/crew/main.py","lineNumber":78,"sourceCode":"    try:\n        {{crew_name}}().crew().test(n_iterations=int(sys.argv[1]), eval_llm=sys.argv[2], inputs=inputs)\n\n    except Exception as e:\n        raise Exception(f\"An error occurred while testing the crew: {e}\")\n\ndef run_with_trigger():\n    \"\"\"\n    Run the crew with trigger payload.\n    \"\"\"\n    import json\n\n    if len(sys.argv) < 2:\n        raise Exception(\"No trigger payload provided. Please provide JSON payload as argument.\")\n\n    try:\n        trigger_payload = json.loads(sys.argv[1])\n    except json.JSONDecodeError:\n        raise Exception(\"Invalid JSON payload provided as argument\")\n\n    inputs = {\n        \"crewai_trigger_payload\": trigger_payload,\n        \"topic\": \"\",\n        \"current_year\": \"\"\n    }\n\n    try:\n        result = {{crew_name}}().crew().kickoff(inputs=inputs)\n        return result\n    except Exception as e:\n        raise Exception(f\"An error occurred while running the crew with trigger: {e}\")\n","sourceCodeStart":60,"sourceCodeEnd":91,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/cli/src/crewai_cli/templates/crew/main.py#L60-L91","documentation":"Raised by run_with_trigger() in the crew template when sys.argv[1] cannot be parsed by json.loads. It is a strict input validation error: the trigger payload must be a single valid JSON document supplied as the first CLI argument.","triggerScenarios":"Calling `uv run run_with_trigger '{topic: \"x\"}'` (unquoted keys), passing a file path instead of JSON content, shell-mangled quotes producing broken JSON (e.g. smart quotes from copy-paste), or passing an empty string.","commonSituations":"Shell quoting mistakes with nested quotes around the JSON; payloads pasted from docs containing non-ASCII quotes; a webhook forwarder that URL-encodes or truncates the body before passing it as argv.","solutions":["Validate the payload locally first: `echo '<payload>' | python -m json.tool` to confirm it is valid JSON.","Use single quotes around the whole payload and double quotes inside: `uv run run_with_trigger '{\"topic\": \"AI\"}'`.","For long payloads, write to a file and expand via command substitution: `uv run run_with_trigger \"$(cat payload.json)\"`.","Check for smart quotes or trailing commas introduced by copy-paste."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import json, sys\ntry:\n    payload = json.loads(sys.argv[1])\nexcept json.JSONDecodeError as e:\n    raise SystemExit(f\"Payload is not valid JSON at line {e.lineno} col {e.colno}: {e.msg}\")","typeGuard":"import json\ndef is_valid_json(text: str) -> bool:\n    try:\n        json.loads(text)\n        return True\n    except (json.JSONDecodeError, TypeError):\n        return False","tryCatchPattern":null,"preventionTips":["Pre-validate payloads with `python -m json.tool`","Load large payloads from a file with \\\"$(cat payload.json)\\\" to dodge shell quoting","Beware smart quotes when pasting from browsers/docs"],"tags":["crewai","cli","template","triggers","json","validation"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}