{"record":{"id":"fbe0ed7c4f7adca8","repo":"crewAIInc/crewAI","slug":"url-is-required-either-in-constructor-or-method-ca-fbe0ed","errorCode":null,"errorMessage":"url is required either in constructor or method call","messagePattern":"url is required either in constructor or method call","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/tools/brightdata_tool/brightdata_unlocker.py","lineNumber":118,"sourceCode":"        self.zone = os.getenv(\"BRIGHT_DATA_ZONE\") or \"\"\n        if not self.api_key:\n            raise ValueError(\"BRIGHT_DATA_API_KEY environment variable is required.\")\n        if not self.zone:\n            raise ValueError(\"BRIGHT_DATA_ZONE environment variable is required.\")\n\n    def _run(\n        self,\n        url: str | None = None,\n        format: str | None = None,\n        data_format: str | None = None,\n        **kwargs: Any,\n    ) -> Any:\n        url = url or self.url\n        format = format or self.format\n        data_format = data_format or self.data_format\n\n        if not url:\n            raise ValueError(\"url is required either in constructor or method call\")\n\n        payload = {\n            \"url\": url,\n            \"zone\": self.zone,\n            \"format\": format,\n        }\n        valid_data_formats = {\"html\", \"markdown\"}\n        if data_format not in valid_data_formats:\n            raise ValueError(\n                f\"Unsupported data format: {data_format}. Must be one of {', '.join(valid_data_formats)}.\"\n            )\n\n        if data_format == \"markdown\":\n            payload[\"data_format\"] = \"markdown\"\n\n        headers = {\n            \"Authorization\": f\"Bearer {self.api_key}\",\n            \"Content-Type\": \"application/json\",","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/brightdata_tool/brightdata_unlocker.py#L100-L136","documentation":"Raised by BrightDataUnlockerTool._run when the url parameter is falsy after fallback (url = url or self.url). The unlocker fetches exactly one page per call, and its payload is built around that URL, so no default or inference exists.","triggerScenarios":"Constructing BrightDataUnlockerTool() with no url and calling tool.run(format='markdown'); passing url=None/'' at both constructor and call; agents omitting the url argument.","commonSituations":"Tool instantiated generically for reuse with the URL expected per call but forgotten, empty URL from prompt interpolation, config templates leaving url blank.","solutions":["Pass the URL per call: tool.run(url='https://example.com/pricing').","Or bind it in the constructor: BrightDataUnlockerTool(url='https://example.com/pricing').","Ensure the value is a non-empty http(s) URL string."],"exampleFix":"# before\nresult = tool.run(data_format='markdown')  # ValueError: url is required\n\n# after\nresult = tool.run(url='https://example.com/pricing', data_format='markdown')","handlingStrategy":"validation","validationCode":"def validate_unlock_url(url: str | None) -> str:\n    if not url or not url.startswith((\"http://\", \"https://\")):\n        raise ValueError(\"A fully qualified URL is required for BrightDataUnlockerTool\")\n    return url\n\nresult = tool.run(url=validate_unlock_url(url), data_format='markdown')","typeGuard":"def is_unlocker_call_ready(kwargs: dict, tool) -> bool:\n    return bool(kwargs.get(\"url\") or tool.url)","tryCatchPattern":"try:\n    result = tool.run(data_format='markdown')\nexcept ValueError as e:\n    if \"url is required\" in str(e):\n        result = tool.run(url=get_url_from_context(), data_format='markdown')\n    else:\n        raise","preventionTips":["Bind url in the constructor for single-page targets; validate per-call URLs otherwise.","Reject empty strings from prompt/agent interpolation before tool dispatch.","Remember the unlocker fetches exactly one page per call — there is no batch mode."],"tags":["bright-data","validation","required-parameter","url","web-unlocker"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}