{"record":{"id":"a644ba2befe6a7ad","repo":"crewAIInc/crewAI","slug":"url-is-too-long-max-2048-characters","errorCode":null,"errorMessage":"URL is too long (max 2048 characters)","messagePattern":"URL is too long \\(max 2048 characters\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/tools/selenium_scraping_tool/selenium_scraping_tool.py","lineNumber":33,"sourceCode":"    \"\"\"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\n\n\nclass SeleniumScrapingTool(BaseTool):","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/selenium_scraping_tool/selenium_scraping_tool.py#L15-L51","documentation":"Pydantic field_validator error from SeleniumScrapingToolSchema when website_url exceeds 2048 characters, the common maximum URL length accepted by browsers and servers. Selenium/Chrome cannot reliably navigate to URLs beyond this size, so the validator rejects them early with a clear limit instead of a cryptic browser failure.","triggerScenarios":"Passing a URL longer than 2048 chars — typically a GET URL carrying a huge query string, an encoded blob/token in the query, or accidentally passing a full document/JSON payload instead of a URL.","commonSituations":"URLs with long encoded state, JWTs, or base64 payloads in the query string; accidentally passing HTML content or a data URI where a URL was expected; pasting the wrong variable into website_url.","solutions":["Shorten the URL: move oversized query parameters to a POST body on the target site, or use a shortened/redirect URL.","Double-check the value being passed — a >2048-char 'URL' usually means the wrong data (document, JSON) was supplied.","If a long encoded parameter is unavoidable, host the payload at a short URL and scrape that."],"exampleFix":"# before\ntool = SeleniumScrapingTool(website_url=f\"https://api.example.com/view?data={huge_b64}\", css_element=\"body\")\n#  -> ValueError: URL is too long (max 2048 characters)\n\n# after: host the payload, scrape the short URL\ntool = SeleniumScrapingTool(website_url=\"https://example.com/view/abc123\", css_element=\"body\")","handlingStrategy":"validation","validationCode":"MAX_URL = 2048\nif len(url) > MAX_URL:\n    raise ValueError(f\"URL exceeds {MAX_URL} chars — shorten or host the payload elsewhere\")","typeGuard":null,"tryCatchPattern":"from pydantic import ValidationError\n\ntry:\n    tool = SeleniumScrapingTool(website_url=url, css_element=css)\nexcept ValidationError as e:\n    if \"too long\" in str(e):\n        raise ValueError(\"URL payload too large for GET scraping; use a shortened link\") from e\n    raise","preventionTips":["Check len(url) <= 2048 at ingest time for URLs built from user data.","Keep large state out of URLs — pass it via the target site's POST or hosted endpoints.","A >2048-char URL usually means wrong input (document/JSON); validate the variable you're passing."],"tags":["validation","url","selenium","length-limit"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}