{"record":{"id":"3bdfa9e08528d775","repo":"crewAIInc/crewAI","slug":"parameter-validation-failed-e-s-3bdfa9","errorCode":null,"errorMessage":"Parameter validation failed: {e!s}","messagePattern":"Parameter validation failed: (.+?)","errorType":"validation","errorClass":"BedrockValidationError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/aws/bedrock/knowledge_base/retriever_tool.py","lineNumber":124,"sourceCode":"                if not isinstance(self.next_token, str):\n                    raise BedrockValidationError(\"next_token must be a string\")\n                if len(self.next_token) < 1 or len(self.next_token) > 2048:\n                    raise BedrockValidationError(\n                        \"next_token must be between 1 and 2048 characters\"\n                    )\n                if \" \" in self.next_token:\n                    raise BedrockValidationError(\"next_token cannot contain spaces\")\n\n            if self.number_of_results is not None:\n                if not isinstance(self.number_of_results, int):\n                    raise BedrockValidationError(\"number_of_results must be an integer\")\n                if self.number_of_results < 1:\n                    raise BedrockValidationError(\n                        \"number_of_results must be greater than 0\"\n                    )\n\n        except BedrockValidationError as e:\n            raise BedrockValidationError(f\"Parameter validation failed: {e!s}\") from e\n\n    def _process_retrieval_result(self, result: dict[str, Any]) -> dict[str, Any]:\n        \"\"\"Process a single retrieval result from Bedrock Knowledge Base.\n\n        Args:\n            result (Dict[str, Any]): Raw result from Bedrock Knowledge Base\n\n        Returns:\n            Dict[str, Any]: Processed result with standardized format\n        \"\"\"\n        content_obj = result.get(\"content\", {})\n        content = content_obj.get(\"text\", \"\")\n        content_type = content_obj.get(\"type\", \"text\")\n\n        location = result.get(\"location\", {})\n        location_type = location.get(\"type\", \"unknown\")\n        source_uri = None\n","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/aws/bedrock/knowledge_base/retriever_tool.py#L106-L142","documentation":"This is the catch-all re-raise at the end of _validate_parameters(): any of the individual BedrockValidationError checks (knowledge_base_id format, next_token string/length/spaces, number_of_results type/range) is caught, its message is prefixed with 'Parameter validation failed: ', and it is re-raised with the original as __cause__. The original condition is named after the colon.","triggerScenarios":"Any constructor-time or run-time parameter validation failure, e.g. knowledge_base_id longer than 10 chars, non-alphanumeric knowledge_base_id, or any of errors 200-203. The message after the colon identifies which check fired.","commonSituations":"Generic handler/tests matching on this prefix; log aggregation where the wrapped message appears; developer confusion because the outer message obscures which parameter failed.","solutions":["Read the text after 'Parameter validation failed:' to identify the failing parameter and apply the fix for errors 199-203","Catch BedrockValidationError and inspect str(e) or e.__cause__ to branch on the specific check","Fix the offending parameter value in the tool construction/config"],"exampleFix":"# before\ntry:\n    tool._run('query')\nexcept BedrockValidationError as e:\n    print(e)  # 'Parameter validation failed: ...'\n# after\ntry:\n    tool._run('query')\nexcept BedrockValidationError as e:\n    cause = str(e.__cause__) if e.__cause__ else str(e)\n    logger.error('KB tool validation failed: %s', cause)\n    raise","handlingStrategy":"try-catch","validationCode":"kb = kb.strip()\nassert 1 <= len(kb) <= 10 and kb.isalnum(), 'knowledge_base_id must be <=10 alnum chars'\ntoken = token.strip() if token else None\nif token:\n    assert 1 <= len(token) <= 2048 and ' ' not in token","typeGuard":null,"tryCatchPattern":"try:\n    tool = BedrockKnowledgeBaseRetrievalTool(knowledge_base_id=kb, next_token=tok, number_of_results=n)\nexcept BedrockValidationError as e:\n    specific = str(e.__cause__) if e.__cause__ else str(e)\n    logger.error('invalid KB tool params: %s', specific)\n    raise","preventionTips":["Validate all tool params once in a helper before constructing the tool","Log e.__cause__ to get the specific failing check","Centralize KB tool construction in one place so validation is not duplicated"],"tags":["aws","bedrock","validation","error-wrapping"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}