ComposioActionExecutionError
composio.errors.ComposioActionExecutionError
Stack trace
Traceback (most recent call last):
File "app.py", line 42, in <module>
response = composio_client.execute_action(action_name, params)
File "/usr/local/lib/python3.9/site-packages/composio/client.py", line 88, in execute_action
raise ComposioActionExecutionError(f"Action '{action_name}' failed: {error_msg}")
composio.errors.ComposioActionExecutionError: Action 'generate_report' failed: Invalid API key or insufficient permissions. Why it happens
This error occurs when the Composio client attempts to execute an action but the request fails due to reasons such as invalid or missing API keys, malformed parameters, or internal errors in the Composio service. The client raises this exception to signal that the action could not be completed as requested.
Detection
Catch ComposioActionExecutionError exceptions around action execution calls and log the full error message and parameters to identify the root cause before retrying or failing gracefully.
Causes & fixes
Invalid or missing API key used for authentication
Ensure the API key is correctly set in the environment variable and passed to the Composio client before executing actions.
Action parameters do not conform to the expected schema or required fields are missing
Validate and sanitize all parameters before passing them to the execute_action method, matching the Composio API specification.
Insufficient permissions for the API key to perform the requested action
Verify the API key's permission scope in the Composio dashboard and update it to include the necessary action permissions.
Temporary internal server error or service outage in Composio backend
Implement retry logic with exponential backoff and monitor Composio service status for outages.
Code: broken vs fixed
import os
from composio import ComposioClient
client = ComposioClient(api_key="wrong_or_missing_key")
params = {"report_type": "monthly"}
# This line raises ComposioActionExecutionError
response = client.execute_action("generate_report", params)
print(response) import os
from composio import ComposioClient
# Use environment variable for API key securely
client = ComposioClient(api_key=os.environ["COMPOSIO_API_KEY"])
params = {"report_type": "monthly"}
# Fixed: correct API key and valid parameters
response = client.execute_action("generate_report", params)
print(response) # Should print successful response Workaround
Wrap the execute_action call in try/except ComposioActionExecutionError, log the error details, and optionally retry after a delay or fallback to a safe default action.
Prevention
Use environment variables for API keys, validate all action parameters against Composio's API schema before calls, and implement robust error handling with retries for transient failures.