crewAIInc/crewAI · error · ValueError
dataset_type is required either in constructor or method cal
Error message
dataset_type is required either in constructor or method call
What it means
Raised in BrightDataDatasetTool._run when neither the method call nor the constructor supplied dataset_type. Each parameter falls back to the instance attribute first (dataset_type = dataset_type or self.dataset_type); if both are falsy the tool refuses before making any request.
Source
Thrown at lib/crewai-tools/src/crewai_tools/tools/brightdata_tool/brightdata_dataset.py:566
return await snapshot_response.text()
def _run(
self,
url: str | None = None,
dataset_type: str | None = None,
format: str | None = None,
zipcode: str | None = None,
additional_params: dict[str, Any] | None = None,
**kwargs: Any,
) -> Any:
dataset_type = dataset_type or self.dataset_type
output_format = format or self.format
url = url or self.url
zipcode = zipcode or self.zipcode
additional_params = additional_params or self.additional_params
if not dataset_type:
raise ValueError(
"dataset_type is required either in constructor or method call"
)
if not url:
raise ValueError("url is required either in constructor or method call")
valid_output_formats = {"json", "ndjson", "jsonl", "csv"}
if output_format not in valid_output_formats:
raise ValueError(
f"Unsupported output format: {output_format}. Must be one of {', '.join(valid_output_formats)}."
)
api_key = os.getenv("BRIGHT_DATA_API_KEY")
if not api_key:
raise ValueError("BRIGHT_DATA_API_KEY environment variable is required.")
try:
return asyncio.run(
self.get_dataset_data_async(View on GitHub (pinned to 754d7323be)
Solutions
- Pass dataset_type in the constructor: BrightDataDatasetTool(dataset_type='amazon_product', url=...).
- Or pass it per call: tool.run(url=..., dataset_type='amazon_product').
- Use one of the registry's exact dataset type strings (see filter_dataset_by_id's mapping).
Example fix
# before tool = BrightDataDatasetTool() result = tool.run(url='https://www.amazon.com/dp/B0...') # after tool = BrightDataDatasetTool(dataset_type='amazon_product', url='https://www.amazon.com/dp/B0...') result = tool.run()
Defensive patterns
Strategy: validation
Validate before calling
from crewai_tools.tools.brightdata_tool import BrightDataDatasetTool tool = BrightDataDatasetTool(dataset_type='amazon_product') # bind at construction # any later call is safe: result = tool.run(url='https://www.amazon.com/dp/B0XXXX')
Type guard
def has_dataset_type(call_kwargs: dict, tool: BrightDataDatasetTool) -> bool:
return bool(call_kwargs.get("dataset_type") or tool.dataset_type) Try / catch
try:
result = tool.run(url=url)
except ValueError as e:
if "dataset_type is required" in str(e):
result = tool.run(url=url, dataset_type='amazon_product')
else:
raise Prevention
- Always construct BrightDataDatasetTool with a dataset_type so per-call omission is safe.
- Centralize dataset type names as constants in your codebase.
- Fail fast at startup if required tool config is missing.
When it happens
Trigger: Constructing BrightDataDatasetTool() with no dataset_type and calling _run(url=...) alone; passing dataset_type=None or '' at both levels.
Common situations: Expecting the tool to infer dataset type from the URL (it does not), partial constructor configuration copied from examples, agents omitting the parameter.
Related errors
- Unable to find the dataset for {dataset_type}. Please make s
- url is required either in constructor or method call
- Unsupported output format: {output_format}. Must be one of {
- query is required either in constructor or method call
- url is required either in constructor or method call
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/3422eea05ea163de.
Report an issue: GitHub.