{"record":{"id":"d7b831bd5434f021","repo":"crewAIInc/crewAI","slug":"an-error-occurred-while-plotting-the-flow-e","errorCode":null,"errorMessage":"An error occurred while plotting the flow: {e}","messagePattern":"An error occurred while plotting the flow: (.+?)","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"lib/cli/src/crewai_cli/plot_flow.py","lineNumber":27,"sourceCode":"    \"\"\"\n    from crewai_cli.run_declarative_flow import (\n        configured_project_declarative_flow,\n        plot_declarative_flow_in_project_env,\n    )\n\n    if definition := configured_project_declarative_flow():\n        plot_declarative_flow_in_project_env(definition)\n    else:\n        command = [\"uv\", \"run\", \"plot\"]\n\n        try:\n            subprocess.run(  # noqa: S603\n                command, capture_output=False, text=True, check=True\n            )\n\n        except subprocess.CalledProcessError as e:\n            click.echo(f\"An error occurred while plotting the flow: {e}\", err=True)\n            raise SystemExit(1) from e\n\n        except Exception as e:\n            click.echo(f\"An unexpected error occurred: {e}\", err=True)\n            raise SystemExit(1) from e\n","sourceCodeStart":9,"sourceCodeEnd":32,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/cli/src/crewai_cli/plot_flow.py#L9-L32","documentation":"Printed by the plot-flow command when the underlying `uv run plot` subprocess exits non-zero (CalledProcessError) and no declarative flow definition was found via configured_project_declarative_flow(). The message embeds the exit code and the failing command; the CLI then exits 1. The actual plotting failure happened inside the project's own plot task, and this is the wrapper reporting it.","triggerScenarios":"Running `crewai plot-flow` (or plot_flow()) in a project where `uv run plot` fails: no plot script/task defined in pyproject.toml, missing graphviz system dependency, import errors in the flow module (e.g. undefined LLM env vars), or the flow class failing to instantiate for graph construction.","commonSituations":"Fresh projects without the plot task wired into uv; graphviz not installed (dot binary missing) so diagram export crashes; flows importing API keys at module load that are absent; syntax/import errors introduced in flow code that only surface when the graph builder imports it.","solutions":["Run `uv run plot` directly to see the full traceback the wrapper hides","Install graphviz system package if the error mentions dot/graphviz (apt-get install graphviz / brew install graphviz)","Fix import-time errors in your flow module (missing env vars, typos) exposed by the plot task","Ensure the project defines the plot command/task in pyproject.toml [tool.crewai] or the uv task list"],"exampleFix":"# before\ncrewai plot-flow  # An error occurred while plotting the flow: ... exit 1\n# after (debug directly, fix cause, re-run)\nuv run plot\ncrewai plot-flow","handlingStrategy":"try-catch","validationCode":"import shutil, subprocess\n\ndef plot_prereqs_ok(project_dir: str = \".\") -> bool:\n    has_dot = shutil.which(\"dot\") is not None  # graphviz\n    has_task = subprocess.run(\n        [\"uv\", \"run\", \"plot\", \"--help\"], cwd=project_dir, capture_output=True\n    ).returncode == 0\n    return has_dot and has_task","typeGuard":null,"tryCatchPattern":"try:\n    plot_flow()\nexcept SystemExit:\n    # run `uv run plot` manually to surface the real traceback, fix, re-run\n    raise","preventionTips":["Install graphviz (dot) in environments where you plot flows","Run `uv run plot` directly when debugging plot failures","Keep flow modules import-clean: no missing env vars or side effects at import time"],"tags":["flow","visualization","subprocess","cli"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}