{"record":{"id":"3422eea05ea163de","repo":"crewAIInc/crewAI","slug":"dataset-type-is-required-either-in-constructor-or","errorCode":null,"errorMessage":"dataset_type is required either in constructor or method call","messagePattern":"dataset_type is required either in constructor or method call","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/tools/brightdata_tool/brightdata_dataset.py","lineNumber":566,"sourceCode":"                return await snapshot_response.text()\n\n    def _run(\n        self,\n        url: str | None = None,\n        dataset_type: str | None = None,\n        format: str | None = None,\n        zipcode: str | None = None,\n        additional_params: dict[str, Any] | None = None,\n        **kwargs: Any,\n    ) -> Any:\n        dataset_type = dataset_type or self.dataset_type\n        output_format = format or self.format\n        url = url or self.url\n        zipcode = zipcode or self.zipcode\n        additional_params = additional_params or self.additional_params\n\n        if not dataset_type:\n            raise ValueError(\n                \"dataset_type is required either in constructor or method call\"\n            )\n        if not url:\n            raise ValueError(\"url is required either in constructor or method call\")\n\n        valid_output_formats = {\"json\", \"ndjson\", \"jsonl\", \"csv\"}\n        if output_format not in valid_output_formats:\n            raise ValueError(\n                f\"Unsupported output format: {output_format}. Must be one of {', '.join(valid_output_formats)}.\"\n            )\n\n        api_key = os.getenv(\"BRIGHT_DATA_API_KEY\")\n        if not api_key:\n            raise ValueError(\"BRIGHT_DATA_API_KEY environment variable is required.\")\n\n        try:\n            return asyncio.run(\n                self.get_dataset_data_async(","sourceCodeStart":548,"sourceCodeEnd":584,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/brightdata_tool/brightdata_dataset.py#L548-L584","documentation":"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.","triggerScenarios":"Constructing BrightDataDatasetTool() with no dataset_type and calling _run(url=...) alone; passing dataset_type=None or '' at both levels.","commonSituations":"Expecting the tool to infer dataset type from the URL (it does not), partial constructor configuration copied from examples, agents omitting the parameter.","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)."],"exampleFix":"# before\ntool = BrightDataDatasetTool()\nresult = tool.run(url='https://www.amazon.com/dp/B0...')\n\n# after\ntool = BrightDataDatasetTool(dataset_type='amazon_product', url='https://www.amazon.com/dp/B0...')\nresult = tool.run()","handlingStrategy":"validation","validationCode":"from crewai_tools.tools.brightdata_tool import BrightDataDatasetTool\n\ntool = BrightDataDatasetTool(dataset_type='amazon_product')  # bind at construction\n# any later call is safe:\nresult = tool.run(url='https://www.amazon.com/dp/B0XXXX')","typeGuard":"def has_dataset_type(call_kwargs: dict, tool: BrightDataDatasetTool) -> bool:\n    return bool(call_kwargs.get(\"dataset_type\") or tool.dataset_type)","tryCatchPattern":"try:\n    result = tool.run(url=url)\nexcept ValueError as e:\n    if \"dataset_type is required\" in str(e):\n        result = tool.run(url=url, dataset_type='amazon_product')\n    else:\n        raise","preventionTips":["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."],"tags":["bright-data","validation","required-parameter","dataset"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}