{"record":{"id":"e1a43243fa5e9265","repo":"crewAIInc/crewAI","slug":"invalid-parameters-e","errorCode":null,"errorMessage":"Invalid parameters: {e}","messagePattern":"Invalid parameters: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/tools/brave_search_tool/base.py","lineNumber":258,"sourceCode":"\r\n        # All retries exhausted — last_resp is always set when we reach here\r\n        _raise_for_error(last_resp or resp)\r\n        return {}  # unreachable; satisfies return type\r\n\r\n    def _run(self, q: str | None = None, **params: Any) -> Any:\r\n        # Allow positional usage: tool.run(\"latest Brave browser features\")\r\n        if q is not None:\r\n            params[\"q\"] = q\r\n\r\n        params = self._common_payload_refinement(params)\r\n\r\n        schema_keys = self.args_schema.model_fields\r\n        payload_in = {k: v for k, v in params.items() if k in schema_keys}\r\n\r\n        try:\r\n            validated = self.args_schema(**payload_in)\r\n        except Exception as e:\r\n            raise ValueError(f\"Invalid parameters: {e}\") from e\r\n\r\n        # The subclass may have additional refinements to apply to the payload, such as goggles or other parameters\r\n        payload = self._refine_request_payload(validated.model_dump(exclude_none=True))\r\n        response = self._make_request(payload)\r\n\r\n        if not self.raw:\r\n            response = self._refine_response(response)\r\n\r\n        if self.save_file:\r\n            _save_results_to_file(json.dumps(response, indent=2))\r\n\r\n        return response\r\n\r\n    @abstractmethod\r\n    def _refine_request_payload(self, params: dict[str, Any]) -> dict[str, Any]:\r\n        \"\"\"Subclass must implement: transform validated params dict into API request params.\"\"\"\r\n        raise NotImplementedError\r\n\r","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/brave_search_tool/base.py#L240-L276","documentation":"Raised by the Brave search tool base class when the request parameters fail validation against the tool's pydantic args_schema. Before validating, _run filters incoming params to known schema fields, so this fires when a retained field has an invalid type or value (e.g. count out of range, wrong enum for country/search_lang). The original pydantic ValidationError is chained as the cause and its text is embedded in the message.","triggerScenarios":"Calling tool.run(q=..., count='ten') or passing an invalid country code like country='XX' or an unknown freshness/goggles value; an LLM agent filling a parameter with a placeholder like \"null\" or [] for a required field (the empty-value scrubber in _common_payload_refinement only strips optional fields).","commonSituations":"Agent frameworks (crewAI strict-mode schema pipelines mark all fields required, so LLMs stuff placeholders into required fields), typos in parameter names that collide with real fields, version changes where the args_schema gained stricter constraints.","solutions":["Read the embedded pydantic message: it names the exact field and constraint that failed.","Check the tool's args_schema (e.g. BraveSearchToolSchema) for the field's type, enum, or numeric bounds and pass a conforming value.","If an LLM is producing the call, ensure required fields get real values, not 'null'/''/[] placeholders.","Pass the query positionally: tool.run('latest Brave browser features') to avoid misnamed kwargs."],"exampleFix":"# before\ntool.run(q='crewai', count='ten', country='XX')\n\n# after\nfrom crewai_tools.tools.brave_search_tool import BraveSearchTool\ntool = BraveSearchTool()\nresult = tool.run(q='crewai', count=10, country='us')","handlingStrategy":"validation","validationCode":"from crewai_tools.tools.brave_search_tool import BraveSearchTool\n\ntool = BraveSearchTool()\nparams = {\"q\": \"crewai\", \"count\": 10, \"country\": \"us\"}\n# Dry-run the schema before the real call\ntool.args_schema(**{k: v for k, v in params.items() if k in tool.args_schema.model_fields})","typeGuard":null,"tryCatchPattern":"try:\n    result = tool.run(q=query, count=10)\nexcept ValueError as e:\n    # message embeds the pydantic ValidationError details\n    if str(e).startswith(\"Invalid parameters:\"):\n        log_bad_params(query, e)\n        result = tool.run(q=query)  # retry with minimal safe params\n    else:\n        raise","preventionTips":["Pre-validate arguments against tool.args_schema before invoking the tool.","Pass the search string positionally to avoid misnamed kwargs.","Strip placeholder values ('null', '', []) from LLM-generated tool calls before dispatch."],"tags":["brave-search","pydantic","validation","parameter-validation"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}