{"record":{"id":"aab5d21141e67e5d","repo":"crewAIInc/crewAI","slug":"you-must-pass-oxylabs-username-and-password-when-i-aab5d2","errorCode":null,"errorMessage":"You must pass oxylabs username and password when instantiating the tool or specify OXYLABS_USERNAME and OXYLABS_PASSWORD environment variables","messagePattern":"You must pass oxylabs username and password when instantiating the tool or specify OXYLABS_USERNAME and OXYLABS_PASSWORD environment variables","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/tools/oxylabs_universal_scraper_tool/oxylabs_universal_scraper_tool.py","lineNumber":145,"sourceCode":"                        password=password,\n                        sdk_type=sdk_type,\n                    )\n                except subprocess.CalledProcessError as e:\n                    raise ImportError(\"Failed to install oxylabs package\") from e\n            else:\n                raise ImportError(\n                    \"`oxylabs` package not found, please run `uv add oxylabs`\"\n                )\n\n        if config is None:\n            config = OxylabsUniversalScraperConfig()\n        super().__init__(config=config, **kwargs)\n\n    def _get_credentials_from_env(self) -> tuple[str, str]:\n        username = os.environ.get(\"OXYLABS_USERNAME\")\n        password = os.environ.get(\"OXYLABS_PASSWORD\")\n        if not username or not password:\n            raise ValueError(\n                \"You must pass oxylabs username and password when instantiating the tool \"\n                \"or specify OXYLABS_USERNAME and OXYLABS_PASSWORD environment variables\"\n            )\n        return username, password\n\n    def _run(self, url: str) -> str:\n        response = self.oxylabs_api.universal.scrape_url(\n            url,\n            **self.config.model_dump(exclude_none=True),\n        )\n\n        content = response.results[0].content\n\n        if isinstance(content, dict):\n            return json.dumps(content)\n\n        return str(content)\n","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/oxylabs_universal_scraper_tool/oxylabs_universal_scraper_tool.py#L127-L163","documentation":"Raised by OxylabsUniversalScraperTool when no Oxylabs credentials are supplied. The tool needs a username/password pair for the Oxylabs web scraping API; it looks for constructor arguments first and falls back to the OXYLABS_USERNAME and OXYLABS_PASSWORD environment variables. If neither source yields both values, this ValueError is thrown before any scraping happens.","triggerScenarios":"Instantiating OxylabsUniversalScraperTool() without username/password arguments while OXYLABS_USERNAME or OXYLABS_PASSWORD (or both) is unset or empty in the environment. The check happens in _get_credentials_from_env, which is called during setup when explicit credentials are absent.","commonSituations":"Running in a new shell/CI container where the env vars were never exported, setting only one of the two variables, misspelling the variable names, or passing credentials via a .env file that the process never loaded.","solutions":["Set both environment variables: export OXYLABS_USERNAME=... and export OXYLABS_PASSWORD=..., then rerun","Pass credentials explicitly: OxylabsUniversalScraperTool(username='...', password='...')","If using a .env file, load it before tool creation (e.g. python-dotenv load_dotenv()) and verify with os.environ.get","Check for typos/whitespace in the variable names and values (print(bool(os.environ.get('OXYLABS_USERNAME'))) to verify)"],"exampleFix":"# before\ntool = OxylabsUniversalScraperTool()  # raises ValueError: no credentials\n\n# after\nimport os\nfrom crewai_tools.tools.oxylabs_universal_scraper_tool import OxylabsUniversalScraperTool\n\ntool = OxylabsUniversalScraperTool(\n    username=os.environ[\"OXYLABS_USERNAME\"],\n    password=os.environ[\"OXYLABS_PASSWORD\"],\n)","handlingStrategy":"validation","validationCode":"import os\n\ndef has_oxylabs_creds() -> bool:\n    return bool(os.environ.get(\"OXYLABS_USERNAME\")) and bool(os.environ.get(\"OXYLABS_PASSWORD\"))\n\nassert has_oxylabs_creds(), \"Set OXYLABS_USERNAME and OXYLABS_PASSWORD before creating the tool\"","typeGuard":null,"tryCatchPattern":"try:\n    tool = OxylabsUniversalScraperTool(username=u, password=p)\nexcept ValueError as e:\n    if \"OXYLABS\" in str(e):\n        raise SystemExit(\"Missing Oxylabs credentials: export OXYLABS_USERNAME/OXYLABS_PASSWORD\") from e\n    raise","preventionTips":["Export both env vars in shell profile or CI secrets","Pass credentials as constructor args in scripts so they never depend on ambient env","Fail fast at startup with an env-var check instead of at tool construction inside agent loops","Never hardcode credentials; use a secrets manager or env file that is definitely loaded"],"tags":["credentials","configuration","environment-variables","oxylabs","scraper"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}