{"id":"fdadafabeb86747f","repo":"boto/boto3","slug":"unsupported-type-type-value-for-value-value","errorCode":null,"errorMessage":"Unsupported type \"{type(value)}\" for value \"{value}\"","messagePattern":"Unsupported type \"(.+?)\" for value \"(.+?)\"","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"boto3/dynamodb/types.py","lineNumber":153,"sourceCode":"\n        elif self._is_type_set(value, self._is_number):\n            dynamodb_type = NUMBER_SET\n\n        elif self._is_type_set(value, self._is_string):\n            dynamodb_type = STRING_SET\n\n        elif self._is_type_set(value, self._is_binary):\n            dynamodb_type = BINARY_SET\n\n        elif self._is_map(value):\n            dynamodb_type = MAP\n\n        elif self._is_listlike(value):\n            dynamodb_type = LIST\n\n        else:\n            msg = f'Unsupported type \"{type(value)}\" for value \"{value}\"'\n            raise TypeError(msg)\n\n        return dynamodb_type\n\n    def _is_null(self, value):\n        if value is None:\n            return True\n        return False\n\n    def _is_boolean(self, value):\n        if isinstance(value, bool):\n            return True\n        return False\n\n    def _is_number(self, value):\n        if isinstance(value, (int, Decimal)):\n            return True\n        elif isinstance(value, float):\n            raise TypeError(","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/boto/boto3/blob/c7b4afac237b976d48395d7523eaf7cec3a450b3/boto3/dynamodb/types.py#L135-L171","documentation":"Raised by TypeSerializer._get_dynamodb_type when serialize() receives a Python value that matches none of the supported DynamoDB type checks (None, bool, int/Decimal, str, Binary/bytes/bytearray, sets of those, Mapping, list/tuple). The serializer dispatches on type; an unrecognized type (custom object, datetime, complex, frozenset of unsupported, etc.) cannot be mapped to a DynamoDB type and is rejected.","triggerScenarios":"table.put_item(Item={'when': datetime.now()}) — datetime is unsupported. Also serialize(complex(1,2)), serialize(object()), or a set containing mixed/unsupported types. Note: float is caught separately (see error 10), and frozenset of unsupported inner types falls through here.","commonSituations":"Storing datetime/date objects without conversion to ISO strings; storing custom dataclass/pydantic objects without dict conversion; sets mixing types that fail every _is_type_set check.","solutions":["Convert datetime/date to ISO-format strings: dt.isoformat().","Convert custom objects to dicts or primitives before putting.","Ensure sets are homogeneous (all int/Decimal, all str, or all bytes/Binary).","Use Decimal for all numbers instead of float or numeric strings."],"exampleFix":"# before\nfrom datetime import datetime\ntable.put_item(Item={'ts': datetime.now()})\n\n# after\ntable.put_item(Item={'ts': datetime.now().isoformat()})","handlingStrategy":"validation","validationCode":"from datetime import date, datetime\nfrom decimal import Decimal\n\ndef normalize_for_dynamodb(value):\n    if isinstance(value, (datetime, date)):\n        return value.isoformat()\n    if isinstance(value, float):\n        return Decimal(str(value))\n    if hasattr(value, '__dict__') and not isinstance(value, (str, bytes, bytearray)):\n        return {k: normalize_for_dynamodb(v) for k, v in vars(value).items()}\n    return value\n\ndef normalize_item(item):\n    return {k: normalize_for_dynamodb(v) for k, v in item.items()}","typeGuard":"from decimal import Decimal\nfrom boto3.dynamodb.types import Binary\n\ndef is_dynamodb_supported(v) -> bool:\n    return isinstance(v, (type(None), bool, int, Decimal, str, bytes, bytearray, Binary, list, tuple, dict, set))","tryCatchPattern":"try:\n    table.put_item(Item=item)\nexcept TypeError as e:\n    if 'Unsupported type' in str(e):\n        item = normalize_item(item)\n        table.put_item(Item=item)\n    else:\n        raise","preventionTips":["Run every Item dict through a normalizer that converts datetime/float/custom objects.","Keep a whitelist of allowed types at the boundary of your DynamoDB layer.","Use Decimal consistently for numbers to avoid float pitfalls."],"tags":["dynamodb","types","serialization","type-error"],"analyzedSha":"c7b4afac237b976d48395d7523eaf7cec3a450b3","analyzedAt":"2026-08-04T20:35:51.598Z","schemaVersion":2}