BerriAI/litellm · error · AwsAuthError

Invalid web identity token reference.

Error message

Invalid web identity token reference.

What it means

Security guard in the web-identity auth path: the aws_web_identity_token value is a reference (e.g. 'os.environ/<VAR>' or a bare env-var name) rather than an actual token. Because caller-supplied references are not expanded here, the malformed token reference is rejected.

Solutions

  1. Set aws_web_identity_token to a valid file path or token value.
  2. Verify AWS_WEB_IDENTITY_TOKEN_FILE points to a readable token file.
  3. Check the web identity token configuration in your environment.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/llms/bedrock/base_aws_llm.py:824 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/05b97220abff88a0. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/bedrock/base_aws_llm.py:824

        """
        Authenticate with AWS Web Identity Token
        """
        import boto3

        verbose_logger.debug(
            "IN Web Identity Token: %s | Role Name: %s | Session Name: %s",
            aws_web_identity_token,
            aws_role_name,
            aws_session_name,
        )

        # get_secret() expands environment-variable references (an os.environ/<VAR>
        # prefix, or a bare name matching an environment variable). Config-sourced
        # references are expanded at load time, so such a reference reaching here is
        # caller-supplied input; reject it rather than expanding a process-environment
        # value for use as the token.
        if aws_web_identity_token.startswith("os.environ/") or aws_web_identity_token in os.environ:
            raise AwsAuthError(
                message="Invalid web identity token reference.",
                status_code=400,
            )

        oidc_token: Final = get_secret(aws_web_identity_token)

        if oidc_token is None:
            raise AwsAuthError(
                message="OIDC token could not be retrieved from secret manager.",
                status_code=401,
            )

        sts_client_kwargs: Final = self._build_sts_client_kwargs(
            aws_sts_endpoint=aws_sts_endpoint,
            ssl_verify=ssl_verify,
        )

        with tracer.trace("boto3.client(sts)"):

View on GitHub (pinned to 77b7c6c40c)