Skip to content

ValidationException dataclass

Bases: ServiceError

The input fails to satisfy the constraints specified by Amazon Bedrock. For troubleshooting this error, see ValidationError in the Amazon Bedrock User Guide

Source code in src/aws_sdk_bedrock_runtime/models.py
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
@dataclass(kw_only=True)
class ValidationException(ServiceError):
    """The input fails to satisfy the constraints specified by *Amazon
    Bedrock*. For troubleshooting this error, see
    [ValidationError](https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-validation-error)
    in the Amazon Bedrock User Guide
    """

    fault: Literal["client", "server"] | None = "client"

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_VALIDATION_EXCEPTION, self)

    def serialize_members(self, serializer: ShapeSerializer):
        if self.message is not None:
            serializer.write_string(
                _SCHEMA_VALIDATION_EXCEPTION.members["message"], self.message
            )

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(**cls.deserialize_kwargs(deserializer))

    @classmethod
    def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]:
        kwargs: dict[str, Any] = {}

        def _consumer(schema: Schema, de: ShapeDeserializer) -> None:
            match schema.expect_member_index():
                case 0:
                    kwargs["message"] = de.read_string(
                        _SCHEMA_VALIDATION_EXCEPTION.members["message"]
                    )

                case _:
                    logger.debug("Unexpected member schema: %s", schema)

        deserializer.read_struct(_SCHEMA_VALIDATION_EXCEPTION, consumer=_consumer)
        return kwargs