{"record":{"id":"86537bdf8da4d585","repo":"crewAIInc/crewAI","slug":"error-executing-crew-with-trigger-e","errorCode":null,"errorMessage":"Error executing crew with trigger: {e}","messagePattern":"Error executing crew with trigger: (.+?)","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"lib/cli/src/crewai_cli/triggers/main.py","lineNumber":71,"sourceCode":"            if response.status_code == 404:\n                error_data = response.json()\n                console.print(\n                    f\"[bold red]Error: {error_data.get('error', 'Trigger not found')}[/bold red]\"\n                )\n                raise SystemExit(1)\n\n            self._validate_response(response)\n\n            trigger_data = response.json()\n            self._display_trigger_info(trigger_data)\n\n            self._run_crew_with_payload(trigger_data.get(\"sample_payload\", {}))\n\n        except Exception as e:\n            console.print(\n                f\"[bold red]Error executing crew with trigger: {e}[/bold red]\"\n            )\n            raise SystemExit(1) from e\n\n    def _display_triggers(self, triggers_data: dict[str, Any]) -> None:\n        \"\"\"Display triggers in a formatted table.\"\"\"\n        apps = triggers_data.get(\"apps\", [])\n\n        if not apps:\n            console.print(\"[yellow]No triggers found.[/yellow]\")\n            return\n\n        for app in apps:\n            app_name = app.get(\"name\", \"Unknown App\")\n            app_slug = app.get(\"slug\", \"unknown\")\n            is_connected = app.get(\"is_connected\", False)\n            connection_status = (\n                \"[green]✓ Connected[/green]\"\n                if is_connected\n                else \"[red]✗ Not Connected[/red]\"\n            )","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/cli/src/crewai_cli/triggers/main.py#L53-L89","documentation":"Printed with SystemExit(1) by TriggerCommand.execute_with_trigger() as the outer catch-all: any exception after the 404 check — _validate_response failures (auth/5xx), JSON decode errors on the response, or failures inside _run_crew_with_payload when spawning the local crew process with the sample payload — surfaces as 'Error executing crew with trigger: {e}'.","triggerScenarios":"Plus API returns 401/500 for get_trigger_payload (non-404 error statuses); response body is not JSON; or the local crew run (`run_with_trigger` subprocess with the sample payload) fails — e.g. missing API keys for the crew itself, or the generated main.py lacking a run_with_trigger entrypoint.","commonSituations":"Expired Plus token mid-session; crew project not created from a template that supports triggers, so executing the payload locally crashes; crew env vars missing so the subprocess exits non-zero.","solutions":["Read the inner exception text after the colon — it distinguishes API errors from local crew execution failures.","For API auth errors, re-run `crewai login` and retry.","For local crew failures, first make a plain `crewai run` work, then retry `crewai trigger execute app/trigger`.","Ensure the project was scaffolded with trigger support (main.py contains run_with_trigger) and is up to date (`crewai update` or re-scaffold)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# validate auth + local runnability before executing a trigger\nassert auth.get_api_key(), \"run `crewai login` first\"\nimport subprocess\nassert subprocess.run([\"uv\", \"run\", \"run\"], capture_output=True).returncode == 0, \"plain `crewai run` must succeed first\"","typeGuard":null,"tryCatchPattern":"try:\n    cmd.execute_with_trigger(trigger_path)\nexcept SystemExit:\n    raise\nexcept Exception as e:\n    # read inner text: API auth/5xx vs local crew subprocess failure\n    logging.exception(\"trigger execution failed: %s\", e)\n    raise","preventionTips":["Get `crewai run` green before wiring triggers","Keep the Plus token fresh; re-login on 401s","Scaffold with trigger-capable templates and keep the CLI/crewai versions in sync"],"tags":["crewai","cli","triggers","catch-all","network"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}