{"record":{"id":"e5ac689a85f6993d","repo":"crewAIInc/crewAI","slug":"you-must-pass-oxylabs-username-and-password-when-i","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_amazon_product_scraper_tool/oxylabs_amazon_product_scraper_tool.py","lineNumber":149,"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 = OxylabsAmazonProductScraperConfig()\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) -> str:\n        response = self.oxylabs_api.amazon.scrape_product(\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":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/oxylabs_amazon_product_scraper_tool/oxylabs_amazon_product_scraper_tool.py#L131-L167","documentation":"OxylabsAmazonProductScraperTool needs credentials. If username/password are not passed as constructor arguments, it falls back to _get_credentials_from_env, which raises ValueError when either OXYLABS_USERNAME or OXYLABS_PASSWORD is missing or empty.","triggerScenarios":"OxylabsAmazonProductScraperTool() with no args while OXYLABS_USERNAME/OXYLABS_PASSWORD are unset; or one of the two env vars set to an empty string; or env vars set in a shell but not exported / not visible to the process (docker, systemd, IDE).","commonSituations":"Secrets stored in .env but not loaded (no dotenv in the entrypoint); running in Docker without passing -e/--env-file; CI secrets not configured; shell vs subprocess env differences.","solutions":["Pass credentials explicitly: OxylabsAmazonProductScraperTool(username=..., password=...).","Or export both env vars in the process environment: export OXYLABS_USERNAME=... OXYLABS_PASSWORD=... (and load .env files with python-dotenv before construction).","In Docker/CI, inject them via --env-file or platform secret variables and confirm with print(bool(os.environ.get('OXYLABS_USERNAME')))."],"exampleFix":"# before\ntool = OxylabsAmazonProductScraperTool()  # ValueError\n\n# after\nimport os\nfrom dotenv import load_dotenv\nload_dotenv()\ntool = OxylabsAmazonProductScraperTool(\n    username=os.environ[\"OXYLABS_USERNAME\"],\n    password=os.environ[\"OXYLABS_PASSWORD\"],\n)","handlingStrategy":"validation","validationCode":"import os\n\ndef oxylabs_creds_ready() -> bool:\n    return bool(os.environ.get(\"OXYLABS_USERNAME\")) and bool(os.environ.get(\"OXYLABS_PASSWORD\"))\n\nif not oxylabs_creds_ready():\n    raise SystemExit(\"Set OXYLABS_USERNAME and OXYLABS_PASSWORD (or pass username/password)\")","typeGuard":null,"tryCatchPattern":"try:\n    tool = OxylabsAmazonProductScraperTool()\nexcept ValueError as e:\n    if \"username and password\" in str(e):\n        tool = OxylabsAmazonProductScraperTool(username=get_user(), password=get_pass())","preventionTips":["Load .env with python-dotenv before constructing the tool.","Pass credentials explicitly in code when env plumbing is uncertain.","Wire OXYLABS_USERNAME/OXYLABS_PASSWORD as CI/Docker secrets and verify at startup."],"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"}