crewAIInc/crewAI · error · ValueError
Website URL cannot be empty
Error message
Website URL cannot be empty
What it means
Pydantic field_validator error raised while constructing SeleniumScrapingToolSchema when website_url is an empty string. The schema marks website_url as mandatory (Field(...)) and the validator rejects falsy values before any Selenium activity starts. Note it only fires for empty strings — None bypasses this branch in some Pydantic versions and is caught by later required-field enforcement.
Source
Thrown at lib/crewai-tools/src/crewai_tools/tools/selenium_scraping_tool/selenium_scraping_tool.py:30
class SeleniumScrapingToolSchema(FixedSeleniumScrapingToolSchema):
"""Input for SeleniumScrapingTool."""
website_url: str = Field(
...,
description="Mandatory website url to read the file. Must start with http:// or https://",
)
css_element: str = Field(
...,
description="Mandatory css reference for element to scrape from the website",
)
@field_validator("website_url")
@classmethod
def validate_website_url(cls, v: str) -> str:
if not v:
raise ValueError("Website URL cannot be empty")
if len(v) > 2048: # Common maximum URL length
raise ValueError("URL is too long (max 2048 characters)")
if not re.match(r"^https?://", v):
raise ValueError("URL must start with http:// or https://")
try:
result = urlparse(v)
if not all([result.scheme, result.netloc]):
raise ValueError("Invalid URL format")
except Exception as e:
raise ValueError(f"Invalid URL: {e!s}") from e
if re.search(r"\s", v):
raise ValueError("URL cannot contain whitespace")
return vView on GitHub (pinned to 754d7323be)
Solutions
- Supply a non-empty website_url when creating the tool or invoking run: SeleniumScrapingTool(website_url='https://example.com', css_element='article').
- Validate upstream input for emptiness before constructing the tool (check `if not url.strip()`).
- If URLs come from data, filter or skip rows with empty URL values.
Example fix
# before tool = SeleniumScrapingTool(website_url="", css_element="h1") # ValidationError # after url = url.strip() or "https://fallback.example.com" tool = SeleniumScrapingTool(website_url=url, css_element="h1")
Defensive patterns
Strategy: validation
Validate before calling
url = (url or "").strip()
if not url:
raise ValueError("website_url must be a non-empty string")
tool = SeleniumScrapingTool(website_url=url, css_element="article") Try / catch
from pydantic import ValidationError
try:
tool = SeleniumScrapingTool(website_url=url, css_element=css)
except ValidationError as e:
if any(err['type'] == 'value_error' and 'empty' in err['msg'] for err in e.errors()):
url = DEFAULT_URL
tool = SeleniumScrapingTool(website_url=url, css_element=css)
raise Prevention
- Strip and check URL strings for emptiness before building the tool.
- Treat empty URL as missing data upstream: skip the row/abort the task rather than passing ''.
- Centralize URL normalization in one helper used by every scraping call.
When it happens
Trigger: Passing SeleniumScrapingToolSchema(website_url='') or SeleniumScrapingTool.run with an empty string URL; e.g. building the schema from user input or config where the URL field was left blank.
Common situations: Form or config-driven tool creation where the URL field is optional in the UI but required by the tool; reading URLs from a file/column where some rows are empty; an agent passing '' because it extracted no URL from the task.
Related errors
- URL cannot be empty
- Invalid URL format. URL must include scheme (http/https) and
- URL is too long (max 2048 characters)
- URL must start with http:// or https://
- Invalid URL format
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/4fa1f7ed921273d4.
Report an issue: GitHub.