crewAIInc/crewAI · error · BedrockValidationError

Parameter validation failed: {e!s}

Error message

Parameter validation failed: {e!s}

What it means

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.

Source

Thrown at lib/crewai-tools/src/crewai_tools/aws/bedrock/knowledge_base/retriever_tool.py:124

                if not isinstance(self.next_token, str):
                    raise BedrockValidationError("next_token must be a string")
                if len(self.next_token) < 1 or len(self.next_token) > 2048:
                    raise BedrockValidationError(
                        "next_token must be between 1 and 2048 characters"
                    )
                if " " in self.next_token:
                    raise BedrockValidationError("next_token cannot contain spaces")

            if self.number_of_results is not None:
                if not isinstance(self.number_of_results, int):
                    raise BedrockValidationError("number_of_results must be an integer")
                if self.number_of_results < 1:
                    raise BedrockValidationError(
                        "number_of_results must be greater than 0"
                    )

        except BedrockValidationError as e:
            raise BedrockValidationError(f"Parameter validation failed: {e!s}") from e

    def _process_retrieval_result(self, result: dict[str, Any]) -> dict[str, Any]:
        """Process a single retrieval result from Bedrock Knowledge Base.

        Args:
            result (Dict[str, Any]): Raw result from Bedrock Knowledge Base

        Returns:
            Dict[str, Any]: Processed result with standardized format
        """
        content_obj = result.get("content", {})
        content = content_obj.get("text", "")
        content_type = content_obj.get("type", "text")

        location = result.get("location", {})
        location_type = location.get("type", "unknown")
        source_uri = None

View on GitHub (pinned to 754d7323be)

Solutions

  1. Read the text after 'Parameter validation failed:' to identify the failing parameter and apply the fix for errors 199-203
  2. Catch BedrockValidationError and inspect str(e) or e.__cause__ to branch on the specific check
  3. Fix the offending parameter value in the tool construction/config

Example fix

# before
try:
    tool._run('query')
except BedrockValidationError as e:
    print(e)  # 'Parameter validation failed: ...'
# after
try:
    tool._run('query')
except BedrockValidationError as e:
    cause = str(e.__cause__) if e.__cause__ else str(e)
    logger.error('KB tool validation failed: %s', cause)
    raise
Defensive patterns

Strategy: try-catch

Validate before calling

kb = kb.strip()
assert 1 <= len(kb) <= 10 and kb.isalnum(), 'knowledge_base_id must be <=10 alnum chars'
token = token.strip() if token else None
if token:
    assert 1 <= len(token) <= 2048 and ' ' not in token

Try / catch

try:
    tool = BedrockKnowledgeBaseRetrievalTool(knowledge_base_id=kb, next_token=tok, number_of_results=n)
except BedrockValidationError as e:
    specific = str(e.__cause__) if e.__cause__ else str(e)
    logger.error('invalid KB tool params: %s', specific)
    raise

Prevention

When it happens

Trigger: 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.

Common situations: Generic handler/tests matching on this prefix; log aggregation where the wrapped message appears; developer confusion because the outer message obscures which parameter failed.

Related errors


AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15). Data as JSON: /api/errors/3bdfa9e08528d775. Report an issue: GitHub.