crewAIInc/crewAI · error · Exception
Invalid JSON payload provided as argument
Error message
Invalid JSON payload provided as argument
What it means
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.
Source
Thrown at lib/cli/src/crewai_cli/templates/flow/main.py:77
def plot():
content_flow = ContentFlow()
content_flow.plot()
def run_with_trigger():
"""
Run the flow with trigger payload.
"""
import json
import sys
if len(sys.argv) < 2:
raise Exception("No trigger payload provided. Please provide JSON payload as argument.")
try:
trigger_payload = json.loads(sys.argv[1])
except json.JSONDecodeError:
raise Exception("Invalid JSON payload provided as argument")
content_flow = ContentFlow()
try:
result = content_flow.kickoff({"crewai_trigger_payload": trigger_payload})
return result
except Exception as e:
raise Exception(f"An error occurred while running the flow with trigger: {e}")
if __name__ == "__main__":
kickoff()
View on GitHub (pinned to 754d7323be)
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)"`.
Defensive patterns
Strategy: validation
Validate before calling
import json, sys
try:
payload = json.loads(sys.argv[1])
except json.JSONDecodeError as e:
raise SystemExit(f"Invalid JSON: {e.msg} (line {e.lineno})") Type guard
import json
def is_valid_json(text: str) -> bool:
try:
json.loads(text)
return True
except (json.JSONDecodeError, TypeError):
return False Prevention
- Shell-quote the whole JSON in single quotes
- Use \"$(cat payload.json)\" for large payloads
- Validate with json.tool before deploying the trigger
When it happens
Trigger: 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.
Common situations: Nested-quote shell escaping errors; payloads copied from browser/docs with typographic quotes; webhook forwarders double-encoding or truncating the JSON body.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Invalid JSON payload provided as argument
- No trigger payload provided. Please provide JSON payload as
- An error occurred while running the flow with trigger: {e}
- No trigger payload provided. Please provide JSON payload as
- An error occurred while running the crew with trigger: {e}
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/c064a207668250cb.
Report an issue: GitHub.