{"record":{"id":"a7ad26f75d090589","repo":"BerriAI/litellm","slug":"invalid-arn-format-arn","errorCode":null,"errorMessage":"Invalid ARN format: {arn}","messagePattern":"Invalid ARN format: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/chat/agentcore/transformation.py","lineNumber":177,"sourceCode":"        returns: \"arn:aws:bedrock-agentcore:us-west-2:888602223428:runtime/hosted_agent_r9jvp-3ySZuRHjLC\"\n        \"\"\"\n        parts: Final = model.split(\"/\", 1)\n        if len(parts) != 2 or parts[0] != \"agentcore\":\n            raise ValueError(\n                \"Invalid model format. Expected format: 'model=bedrock/agentcore/arn:aws:bedrock-agentcore:region:account:runtime/runtime_id'\"\n            )\n        return parts[1]\n\n    def _extract_region_from_arn(self, arn: str) -> str:\n        \"\"\"\n        Extract region from ARN\n        arn:aws:bedrock-agentcore:us-west-2:888602223428:runtime/hosted_agent_r9jvp-3ySZuRHjLC\n        returns: us-west-2\n        \"\"\"\n        parts: Final = arn.split(\":\")\n        if len(parts) >= 4:\n            return parts[3]\n        raise ValueError(f\"Invalid ARN format: {arn}\")\n\n    def _get_runtime_session_id(self, optional_params: dict) -> str:\n        \"\"\"\n        Get or generate runtime session ID (must be 33+ chars)\n        \"\"\"\n        session_id: Final = optional_params.get(\"runtimeSessionId\", None)\n        if session_id:\n            verbose_logger.debug(\"Using provided runtimeSessionId: %s\", session_id)\n            return session_id\n\n        # Generate a session ID with 33+ characters\n        generated_id: Final = f\"litellm-session-{uuid.uuid4()}\"\n        verbose_logger.debug(\"Generated new session ID: %s\", generated_id)\n        return generated_id\n\n    def _get_runtime_user_id(self, optional_params: dict) -> str | None:\n        \"\"\"\n        Get runtime user ID if provided","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/chat/agentcore/transformation.py#L159-L195","documentation":"_extract_region_from_arn splits the AgentCore ARN on ':' and requires at least 4 parts so that parts[3] (the region) exists. This ValueError is raised when the value after 'agentcore/' is a truncated ARN or a bare runtime identifier — e.g. 'arn:aws:bedrock-agentcore' (3 parts) or 'my-runtime-id' (1 part). It is the second format gate after the prefix check.","triggerScenarios":"model=\"agentcore/hosted_agent_xyz\" (bare runtime id instead of the ARN); an ARN copy-pasted but truncated at the account or service field; CI/CD or env-var interpolation that drops the colon-separated fields; a template with empty {region} that collapses the ARN.","commonSituations":"Using the friendly runtime name shown in the console list view instead of its ARN; long ARNs mangled by YAML folding or shell truncation; building ARNs from templates whose region/account variables are empty.","solutions":["Pass the full runtime ARN after the prefix: agentcore/arn:aws:bedrock-agentcore:region:account:runtime/runtime-id","Validate the ARN has at least 6 colon-separated fields and starts with arn:aws:bedrock-agentcore: before calling litellm","Check env/YAML templates for empty region or account substitutions that silently shrink the ARN"],"exampleFix":"// before\nmodel = \"agentcore/hosted_agent_r9jvp-3ySZuRHjLC\"  // bare runtime id\n\n// after\nmodel = \"agentcore/arn:aws:bedrock-agentcore:us-west-2:888602223428:runtime/hosted_agent_r9jvp-3ySZuRHjLC\"","handlingStrategy":"validation","validationCode":"def assert_full_agentcore_arn(model: str) -> None:\n    arn = model.split(\"/\", 1)[1] if model.startswith(\"agentcore/\") else model\n    parts = arn.split(\":\")\n    if len(parts) < 6 or not parts[3]:\n        raise ValueError(f\"Not a full AgentCore runtime ARN (need >=6 colon fields): {arn!r}\")\n\nassert_full_agentcore_arn(model)\nresp = litellm.completion(model=model, messages=msgs)","typeGuard":"def is_full_agentcore_arn(arn: str) -> bool:\n    \"\"\"True when arn has a region field and the full 6+ part structure.\"\"\"\n    parts = arn.split(\":\")\n    return len(parts) >= 6 and bool(parts[3])","tryCatchPattern":"try:\n    resp = litellm.completion(model=model, messages=msgs)\nexcept ValueError as e:\n    if \"Invalid ARN format\" in str(e):\n        raise ConfigError(f\"AgentCore model must carry the full runtime ARN: {model!r}\") from e\n    raise","preventionTips":["Always pass the console-rendered ARN, not the runtime display name","Lint env-var templates so empty region/account substitutions fail CI","Test ARN length/field count when loading config"],"tags":["bedrock","agentcore","arn","input-validation","aws"],"backgroundTag":"invalid-arn-format","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}