{"record":{"id":"8b99ac2f99ad0243","repo":"crewAIInc/crewAI","slug":"agent-id-cannot-be-empty","errorCode":null,"errorMessage":"agent_id cannot be empty","messagePattern":"agent_id cannot be empty","errorType":"validation","errorClass":"BedrockValidationError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/aws/bedrock/agents/invoke_agent_tool.py","lineNumber":77,"sourceCode":"        # Get values from environment variables if not provided\n        self.agent_id = agent_id or os.getenv(\"BEDROCK_AGENT_ID\")\n        self.agent_alias_id = agent_alias_id or os.getenv(\"BEDROCK_AGENT_ALIAS_ID\")\n        self.session_id = session_id or str(\n            int(time.time())\n        )  # Use timestamp as session ID if not provided\n        self.enable_trace = enable_trace\n        self.end_session = end_session\n\n        if description:\n            self.description = description\n\n        self._validate_parameters()\n\n    def _validate_parameters(self) -> None:\n        \"\"\"Validate the parameters according to AWS API requirements.\"\"\"\n        try:\n            if not self.agent_id:\n                raise BedrockValidationError(\"agent_id cannot be empty\")\n            if not isinstance(self.agent_id, str):\n                raise BedrockValidationError(\"agent_id must be a string\")\n\n            if not self.agent_alias_id:\n                raise BedrockValidationError(\"agent_alias_id cannot be empty\")\n            if not isinstance(self.agent_alias_id, str):\n                raise BedrockValidationError(\"agent_alias_id must be a string\")\n\n            if self.session_id and not isinstance(self.session_id, str):\n                raise BedrockValidationError(\"session_id must be a string\")\n\n        except BedrockValidationError as e:\n            raise BedrockValidationError(f\"Parameter validation failed: {e!s}\") from e\n\n    def _run(self, query: str) -> str:\n        try:\n            import boto3\n            from botocore.exceptions import ClientError","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/aws/bedrock/agents/invoke_agent_tool.py#L59-L95","documentation":"A BedrockValidationError raised in BedrockAgentTools._validate_parameters when the agent_id parameter is falsy (None, empty string). It is immediately re-wrapped as \"Parameter validation failed: agent_id cannot be empty\" by the except block, so the surfaced message is the wrapped form. Validation runs in __init__, so the tool never constructs with an empty agent_id.","triggerScenarios":"Creating BedrockAgentTools (or the underlying invoke-agent tool) with agent_id='' or agent_id=None. Because the empty check precedes the isinstance check, a non-string truthy value fails the next check instead. The except clause at line 90 re-raises the wrapped message.","commonSituations":"Loading agent_id from an env var or config that is unset (defaults to '' or None), template code where the placeholder was never filled in, or passing agentAliasId where agentId was expected so agent_id is left blank.","solutions":["Supply a real Bedrock agent ID: it looks like 'XXXXXXXXXX' (10 alphanumeric chars) from the Bedrock Agents console.","If reading from config/env, fail fast: `agent_id = os.environ['BEDROCK_AGENT_ID']` instead of a silent default.","Check for typos: agent_id is the agent identifier, not the agent name or the alias."],"exampleFix":"# before\ntool = BedrockAgentTools(agent_id=\"\", agent_alias_id=\"TSTALIASID\")\n\n# after\nimport os\ntool = BedrockAgentTools(\n    agent_id=os.environ[\"BEDROCK_AGENT_ID\"],\n    agent_alias_id=os.environ[\"BEDROCK_AGENT_ALIAS_ID\"],\n)","handlingStrategy":"validation","validationCode":"import re\n\ndef valid_agent_id(v) -> bool:\n    return isinstance(v, str) and bool(v.strip())","typeGuard":"def is_agent_id(v) -> bool:\n    return isinstance(v, str) and bool(v)","tryCatchPattern":"try:\n    tool = BedrockAgentTools(agent_id=agent_id, agent_alias_id=alias)\nexcept BedrockValidationError as e:\n    raise ValueError(f\"Bad Bedrock agent config: {e}\") from e","preventionTips":["Source IDs from os.environ[...] (not .get with '' default) so misconfig fails at boot.","Copy agent_id from the Bedrock console, not from memory or names.","Validate config with pydantic (agent_id: str = Field(min_length=1)) before tool creation."],"tags":["aws","bedrock","validation","configuration"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}