crewAIInc/crewAI · error · RuntimeError
FirecrawlApp not properly initialized
Error message
FirecrawlApp not properly initialized
What it means
RuntimeError raised at the top of FirecrawlCrawlWebsiteTool._run when self._firecrawl is falsy — i.e. the FirecrawlApp client was never constructed. Normally __init__ guarantees the client exists, so this fires when construction was bypassed or partially completed (mocked init, subclass skipping super().__init__, or an init path that raised after the check).
Source
Thrown at lib/crewai-tools/src/crewai_tools/tools/firecrawl_crawl_website_tool/firecrawl_crawl_website_tool.py:109
"You are missing the 'firecrawl-py' package. Would you like to install it?"
):
import subprocess
try:
subprocess.run(["uv", "add", "firecrawl-py"], check=True) # noqa: S607
from firecrawl import FirecrawlApp
self._firecrawl = FirecrawlApp(api_key=self.api_key)
except subprocess.CalledProcessError as e:
raise ImportError("Failed to install firecrawl-py package") from e
else:
raise ImportError(
"`firecrawl-py` package not found, please run `uv add firecrawl-py`"
) from None
def _run(self, url: str) -> Any:
if not self._firecrawl:
raise RuntimeError("FirecrawlApp not properly initialized")
url = validate_url(url)
return self._firecrawl.crawl(url=url, poll_interval=2, **self.config)
try:
from firecrawl import FirecrawlApp # noqa: F401
if not getattr(FirecrawlCrawlWebsiteTool, "_model_rebuilt", False):
FirecrawlCrawlWebsiteTool.model_rebuild()
FirecrawlCrawlWebsiteTool._model_rebuilt = True # type: ignore[attr-defined]
except ImportError:
pass
View on GitHub (pinned to 754d7323be)
Solutions
- Construct the tool normally: FirecrawlCrawlWebsiteTool(api_key=...) so _firecrawl is set.
- In tests, inject a mock: tool._firecrawl = MagicMock().
- Don't swallow exceptions from __init__; a failed init should discard the instance, not leave it runnable.
Example fix
# before
tool = FirecrawlCrawlWebsiteTool.__new__(FirecrawlCrawlWebsiteTool)
tool._run('https://x.com') # RuntimeError
# after
tool = FirecrawlCrawlWebsiteTool(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('crawl tool has no FirecrawlApp client; rebuild via constructor') Type guard
def crawl_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):
tool = FirecrawlCrawlWebsiteTool(api_key=KEY)
out = tool._run(url)
else:
raise Prevention
- Only run tools produced by their constructors.
- Inject mock clients in tests rather than leaving internals unset.
When it happens
Trigger: Calling tool._run(url) on an instance created without a completed __init__ (e.g. __new__, model_copy, or a test mock that leaves _firecrawl unset/None).
Common situations: Unit tests with half-mocked tools; Pydantic reconstruction paths; an earlier exception during __init__ being swallowed by a broad except, leaving a half-built object that is then run.
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/3f1233c9f8087fc9.
Report an issue: GitHub.