{"record":{"id":"c064a207668250cb","repo":"crewAIInc/crewAI","slug":"invalid-json-payload-provided-as-argument-c064a2","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/flow/main.py","lineNumber":77,"sourceCode":"def plot():\n    content_flow = ContentFlow()\n    content_flow.plot()\n\n\ndef run_with_trigger():\n    \"\"\"\n    Run the flow with trigger payload.\n    \"\"\"\n    import json\n    import sys\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    content_flow = ContentFlow()\n\n    try:\n        result = content_flow.kickoff({\"crewai_trigger_payload\": trigger_payload})\n        return result\n    except Exception as e:\n        raise Exception(f\"An error occurred while running the flow with trigger: {e}\")\n\n\nif __name__ == \"__main__\":\n    kickoff()\n","sourceCodeStart":59,"sourceCodeEnd":90,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/cli/src/crewai_cli/templates/flow/main.py#L59-L90","documentation":"Raised by run_with_trigger() in the flow template when json.loads(sys.argv[1]) raises JSONDecodeError. Strict validation: the trigger payload must be one valid JSON document supplied as the single CLI argument before the flow kickoff.","triggerScenarios":"Calling the flow entrypoint with malformed JSON — unquoted keys, shell-stripped quotes, smart quotes, trailing commas, a file path instead of contents, or an empty string argument.","commonSituations":"Nested-quote shell escaping errors; payloads copied from browser/docs with typographic quotes; webhook forwarders double-encoding or truncating the JSON body.","solutions":["Lint the payload first: `echo '<payload>' | python -m json.tool`.","Wrap the payload in single quotes and use double quotes inside: `uv run run_with_trigger '{\"key\": 1}'`.","Load from file to avoid shell quoting entirely: `uv run run_with_trigger \"$(cat payload.json)\"`."],"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\"Invalid JSON: {e.msg} (line {e.lineno})\")","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":["Shell-quote the whole JSON in single quotes","Use \\\"$(cat payload.json)\\\" for large payloads","Validate with json.tool before deploying the trigger"],"tags":["crewai","flow","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"}