BerriAI/litellm · error · ValueError

Bedrock guardrail accepts either 'guardrailIdentifier'/'guar

Error message

Bedrock guardrail accepts either 'guardrailIdentifier'/'guardrailVersion' (ApplyGuardrail) or 'checks' (InvokeGuardrailChecks), not both.

What it means

Init validation for the Bedrock guardrail: both ApplyGuardrail-style identifiers (guardrailIdentifier/guardrailVersion) and InvokeGuardrailChecks-style 'checks' were supplied; exactly one mode is allowed because they map to different Bedrock APIs.

Source

Thrown at litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py:252

        self.checks: dict[str, Any] | None = self._normalize_checks(checks)
        # Per-check block thresholds; a score >= threshold blocks. None => the
        # check is detect-only (logged, never blocks).
        self.content_filter_threshold = content_filter_threshold
        self.prompt_attack_threshold = prompt_attack_threshold
        self.pii_confidence_threshold = pii_confidence_threshold

        # store kwargs as optional_params
        self.optional_params = kwargs

        self.disable_exception_on_block: bool = disable_exception_on_block or False
        """
        If True, will not raise an exception when the guardrail is blocked.
        """

        # `checks` (InvokeGuardrailChecks) and `guardrailIdentifier`/`guardrailVersion`
        # (ApplyGuardrail) are two different APIs; configuring both is ambiguous.
        if self.checks is not None and (self.guardrailIdentifier is not None or self.guardrailVersion is not None):
            raise ValueError(
                "Bedrock guardrail accepts either 'guardrailIdentifier'/'guardrailVersion' (ApplyGuardrail) "
                "or 'checks' (InvokeGuardrailChecks), not both."
            )

        # Set supported event hooks to include MCP hooks
        kwargs.setdefault("supported_event_hooks", list(self.get_supported_event_hooks()))

        super().__init__(**kwargs)
        BaseAWSLLM.__init__(self)

        # InvokeGuardrailChecks is detect-only: it never returns rewritten content,
        # so masking has no effect in checks mode.
        if self.checks is not None and (
            getattr(self, "mask_request_content", False) or getattr(self, "mask_response_content", False)
        ):
            verbose_proxy_logger.warning(
                "Bedrock Guardrail: mask_request_content/mask_response_content have no "
                "effect with 'checks' (InvokeGuardrailChecks is detect-only)."

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Configure either guardrailIdentifier/guardrailVersion (ApplyGuardrail) or checks (InvokeGuardrailChecks), not both.

Example fix

Remove the checks block when guardrailIdentifier is set.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py:252 when the library encounters an invalid state.

Common situations: Bedrock guardrail config mixes ApplyGuardrail and InvokeGuardrailChecks modes.


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