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

  1. Lint the payload first: `echo '<payload>' | python -m json.tool`.
  2. Wrap the payload in single quotes and use double quotes inside: `uv run run_with_trigger '{"key": 1}'`.
  3. 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

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

Related errors


AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15). Data as JSON: /api/errors/c064a207668250cb. Report an issue: GitHub.