{"record":{"id":"0ca313e7e4ffe044","repo":"crewAIInc/crewAI","slug":"you-must-pass-oxylabs-username-and-password-when-i-0ca313","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_google_search_scraper_tool/oxylabs_google_search_scraper_tool.py","lineNumber":154,"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 = OxylabsGoogleSearchScraperConfig()\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, query: str, **kwargs: Any) -> str:\n        response = self.oxylabs_api.google.scrape_search(\n            query,\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":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/oxylabs_google_search_scraper_tool/oxylabs_google_search_scraper_tool.py#L136-L172","documentation":"OxylabsGoogleSearchScraperTool._get_credentials_from_env raises ValueError unless both OXYLABS_USERNAME and OXYLABS_PASSWORD are non-empty in the environment, when no username/password constructor args were supplied.","triggerScenarios":"OxylabsGoogleSearchScraperTool() (or with only one of username/password) while one or both of the env vars are unset/empty; env vars present in the deploy config but not in the actual process env.","commonSituations":"Unexported shell vars, missing .env loading, CI secrets not attached, Docker run without -e/--env-file.","solutions":["Provide credentials: OxylabsGoogleSearchScraperTool(username=..., password=...).","Export OXYLABS_USERNAME and OXYLABS_PASSWORD (or load .env with python-dotenv) before construction.","Debug with: python -c \"import os; print(os.environ.get('OXYLABS_USERNAME'), os.environ.get('OXYLABS_PASSWORD'))\"."],"exampleFix":"# before\ntool = OxylabsGoogleSearchScraperTool()  # ValueError\n\n# after\ntool = OxylabsGoogleSearchScraperTool(username=os.environ['OXYLABS_USERNAME'], password=os.environ['OXYLABS_PASSWORD'])","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/OXYLABS_PASSWORD\"","typeGuard":null,"tryCatchPattern":"try:\n    tool = OxylabsGoogleSearchScraperTool()\nexcept ValueError as e:\n    if \"OXYLABS_USERNAME\" in str(e):\n        tool = OxylabsGoogleSearchScraperTool(username=u, password=p)","preventionTips":["Use --env-file / CI secret variables for both OXYLABS_ vars.","Load .env files at process start, not after tool construction."],"tags":["oxylabs","credentials","environment-variables","configuration"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}