{"record":{"id":"4fa1f7ed921273d4","repo":"crewAIInc/crewAI","slug":"website-url-cannot-be-empty","errorCode":null,"errorMessage":"Website URL cannot be empty","messagePattern":"Website URL cannot be empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/tools/selenium_scraping_tool/selenium_scraping_tool.py","lineNumber":30,"sourceCode":"\n\nclass SeleniumScrapingToolSchema(FixedSeleniumScrapingToolSchema):\n    \"\"\"Input for SeleniumScrapingTool.\"\"\"\n\n    website_url: str = Field(\n        ...,\n        description=\"Mandatory website url to read the file. Must start with http:// or https://\",\n    )\n    css_element: str = Field(\n        ...,\n        description=\"Mandatory css reference for element to scrape from the website\",\n    )\n\n    @field_validator(\"website_url\")\n    @classmethod\n    def validate_website_url(cls, v: str) -> str:\n        if not v:\n            raise ValueError(\"Website URL cannot be empty\")\n\n        if len(v) > 2048:  # Common maximum URL length\n            raise ValueError(\"URL is too long (max 2048 characters)\")\n\n        if not re.match(r\"^https?://\", v):\n            raise ValueError(\"URL must start with http:// or https://\")\n\n        try:\n            result = urlparse(v)\n            if not all([result.scheme, result.netloc]):\n                raise ValueError(\"Invalid URL format\")\n        except Exception as e:\n            raise ValueError(f\"Invalid URL: {e!s}\") from e\n\n        if re.search(r\"\\s\", v):\n            raise ValueError(\"URL cannot contain whitespace\")\n\n        return v","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/selenium_scraping_tool/selenium_scraping_tool.py#L12-L48","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\ntool = SeleniumScrapingTool(website_url=\"\", css_element=\"h1\")  # ValidationError\n\n# after\nurl = url.strip() or \"https://fallback.example.com\"\ntool = SeleniumScrapingTool(website_url=url, css_element=\"h1\")","handlingStrategy":"validation","validationCode":"url = (url or \"\").strip()\nif not url:\n    raise ValueError(\"website_url must be a non-empty string\")\ntool = SeleniumScrapingTool(website_url=url, css_element=\"article\")","typeGuard":null,"tryCatchPattern":"from pydantic import ValidationError\n\ntry:\n    tool = SeleniumScrapingTool(website_url=url, css_element=css)\nexcept ValidationError as e:\n    if any(err['type'] == 'value_error' and 'empty' in err['msg'] for err in e.errors()):\n        url = DEFAULT_URL\n        tool = SeleniumScrapingTool(website_url=url, css_element=css)\n    raise","preventionTips":["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."],"tags":["validation","pydantic","selenium","url","required-argument"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}