crewAIInc/crewAI · error · RuntimeError
FirecrawlApp not properly initialized
Error message
FirecrawlApp not properly initialized
What it means
RuntimeError raised at the top of FirecrawlScrapeWebsiteTool._run when self._firecrawl is falsy — the FirecrawlApp client attribute was never populated. __init__ always assigns it on the success path, so this indicates the tool object reached _run without a completed initialization.
Source
Thrown at lib/crewai-tools/src/crewai_tools/tools/firecrawl_scrape_website_tool/firecrawl_scrape_website_tool.py:109
if click.confirm(
"You are missing the 'firecrawl-py' package. Would you like to install it?"
):
import subprocess
subprocess.run(["uv", "add", "firecrawl-py"], check=True) # noqa: S607
from firecrawl import (
FirecrawlApp,
)
else:
raise ImportError(
"`firecrawl-py` package not found, please run `uv add firecrawl-py`"
) from None
self._firecrawl = FirecrawlApp(api_key=api_key)
def _run(self, url: str) -> Any:
if not self._firecrawl:
raise RuntimeError("FirecrawlApp not properly initialized")
url = validate_url(url)
return self._firecrawl.scrape(url=url, **self.config)
try:
from firecrawl import FirecrawlApp # noqa: F401
if not getattr(FirecrawlScrapeWebsiteTool, "_model_rebuilt", False):
FirecrawlScrapeWebsiteTool.model_rebuild()
FirecrawlScrapeWebsiteTool._model_rebuilt = True # type: ignore[attr-defined]
except ImportError:
pass
View on GitHub (pinned to 754d7323be)
Solutions
- Create the tool through its constructor with a valid API key.
- In tests, set tool._firecrawl to a mock before calling _run.
- Let __init__ failures propagate instead of retaining half-initialized tools.
Example fix
# before
tool._firecrawl = None
tool._run('https://x.com') # RuntimeError
# after
tool = FirecrawlScrapeWebsiteTool(api_key=FIRECRAWL_API_KEY)
tool._run('https://x.com') Defensive patterns
Strategy: type-guard
Validate before calling
if not getattr(tool, '_firecrawl', None):
raise RuntimeError('scrape tool lacks FirecrawlApp client') Type guard
def scrape_tool_ready(tool) -> bool:
return bool(getattr(tool, '_firecrawl', None)) Try / catch
try:
out = tool._run(url)
except RuntimeError as e:
if 'not properly initialized' in str(e):
raise # rebuild the tool properly instead of retrying the broken instance Prevention
- Do not reuse instances whose __init__ raised; construct fresh.
- Set tool._firecrawl = MagicMock() in unit tests before calling _run.
When it happens
Trigger: Calling _run(url) on a tool built via __new__/model_copy or a test double that never set _firecrawl; running an instance whose __init__ raised midway and the error was swallowed.
Common situations: Mocked unit tests that forget to inject a client; Pydantic rebuild/copy paths that skip custom __init__; broad except blocks masking init failures.
Related errors
- FirecrawlApp not properly initialized
- FirecrawlApp not properly initialized
- Client not initialized
- Client is not initialized
- Failed to initialize MCP Adapter: {e}
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/a25578d9e1f33717.
Report an issue: GitHub.