crewAIInc/crewAI · error · ValueError

Zapier Actions API key is required

Error message

Zapier Actions API key is required

What it means

Raised by ZapierActionsAdapter.__init__ when neither the `api_key` argument nor the ZAPIER_API_KEY environment variable yields a non-empty key. It is a hard configuration gate: without a key, no Zapier Actions API call can be authenticated.

Source

Thrown at lib/crewai-tools/src/crewai_tools/adapters/zapier_adapter.py:65

            execute_url,
            headers=headers,
            json=action_params,
            timeout=30,
        )

        response.raise_for_status()

        return response.json()


class ZapierActionsAdapter:
    """Adapter for Zapier Actions."""

    def __init__(self, api_key: str | None = None):
        self.api_key = api_key or os.getenv("ZAPIER_API_KEY")
        if not self.api_key:
            logger.error("Zapier Actions API key is required")
            raise ValueError("Zapier Actions API key is required")

    def get_zapier_actions(self) -> Any:
        headers = {
            "x-api-key": self.api_key or "",
        }
        response = requests.request(
            "GET",
            ACTIONS_URL,
            headers=headers,
            timeout=30,
        )
        response.raise_for_status()

        return response.json()

    def tools(self) -> list[ZapierActionTool]:
        """Convert Zapier actions to BaseTool instances."""
        actions_response = self.get_zapier_actions()

View on GitHub (pinned to 754d7323be)

Solutions

  1. Export the key before running: `export ZAPIER_API_KEY=your_key` (or add it to your .env and ensure it is loaded).
  2. Pass it explicitly: `ZapierActionsAdapter(api_key='your_key')`.
  3. In CI/deployment, add ZAPIER_API_KEY as a secret env var on the runner.
  4. Verify with `echo ${ZAPIER_API_KEY:-unset}` that the variable actually reaches the process.

Example fix

# before
adapter = ZapierActionsAdapter()  # ValueError if env var missing

# after
adapter = ZapierActionsAdapter(api_key=os.environ["ZAPIER_API_KEY"])  # fails fast with KeyError if truly missing
# or
export ZAPIER_API_KEY=your_key
Defensive patterns

Strategy: validation

Validate before calling

import os

api_key = os.getenv("ZAPIER_API_KEY")
if not api_key:
    raise SystemExit("ZAPIER_API_KEY is not set — get one at https://zapier.com/appconnections/ai")
adapter = ZapierActionsAdapter(api_key)

Type guard

def has_zapier_key() -> bool:
    return bool(os.getenv("ZAPIER_API_KEY"))

Try / catch

try:
    adapter = ZapierActionsAdapter()
except ValueError as e:
    if "API key" in str(e):
        raise SystemExit("Set ZAPIER_API_KEY in the environment") from e
    raise

Prevention

When it happens

Trigger: Instantiating ZapierActionsAdapter() with no argument while ZAPIER_API_KEY is unset or empty, or passing an empty string api_key explicitly (`api_key=''` falls through to env lookup, which is also empty).

Common situations: Forgot to export ZAPIER_API_KEY in the shell/CI environment, .env file not loaded into the process, key set in a different deployment environment, or a copy-pasted snippet that expects the env var at runtime.

Related errors


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