crewAIInc/crewAI · error · ValueError
You must pass oxylabs username and password when instantiati
Error message
You must pass oxylabs username and password when instantiating the tool or specify OXYLABS_USERNAME and OXYLABS_PASSWORD environment variables
What it means
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.
Source
Thrown at lib/crewai-tools/src/crewai_tools/tools/oxylabs_amazon_product_scraper_tool/oxylabs_amazon_product_scraper_tool.py:149
password=password,
sdk_type=sdk_type,
)
except subprocess.CalledProcessError as e:
raise ImportError("Failed to install oxylabs package") from e
else:
raise ImportError(
"`oxylabs` package not found, please run `uv add oxylabs`"
)
if config is None:
config = OxylabsAmazonProductScraperConfig()
super().__init__(config=config, **kwargs)
def _get_credentials_from_env(self) -> tuple[str, str]:
username = os.environ.get("OXYLABS_USERNAME")
password = os.environ.get("OXYLABS_PASSWORD")
if not username or not password:
raise ValueError(
"You must pass oxylabs username and password when instantiating the tool "
"or specify OXYLABS_USERNAME and OXYLABS_PASSWORD environment variables"
)
return username, password
def _run(self, query: str) -> str:
response = self.oxylabs_api.amazon.scrape_product(
query,
**self.config.model_dump(exclude_none=True),
)
content = response.results[0].content
if isinstance(content, dict):
return json.dumps(content)
return str(content)
View on GitHub (pinned to 754d7323be)
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'))).
Example fix
# before
tool = OxylabsAmazonProductScraperTool() # ValueError
# after
import os
from dotenv import load_dotenv
load_dotenv()
tool = OxylabsAmazonProductScraperTool(
username=os.environ["OXYLABS_USERNAME"],
password=os.environ["OXYLABS_PASSWORD"],
) Defensive patterns
Strategy: validation
Validate before calling
import os
def oxylabs_creds_ready() -> bool:
return bool(os.environ.get("OXYLABS_USERNAME")) and bool(os.environ.get("OXYLABS_PASSWORD"))
if not oxylabs_creds_ready():
raise SystemExit("Set OXYLABS_USERNAME and OXYLABS_PASSWORD (or pass username/password)") Try / catch
try:
tool = OxylabsAmazonProductScraperTool()
except ValueError as e:
if "username and password" in str(e):
tool = OxylabsAmazonProductScraperTool(username=get_user(), password=get_pass()) Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- You must pass oxylabs username and password when instantiati
- You must pass oxylabs username and password when instantiati
- You must pass oxylabs username and password when instantiati
- Scrapegraph API key is required
- API key must be provided either through constructor or MINDS
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/e5ac689a85f6993d.
Report an issue: GitHub.