{"record":{"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":"exception","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/6e10b029c1326a437932a8b24f38af69fd986e15/boto3/dynamodb/types.py#L135-L171","documentation":"TypeSerializer._get_dynamodb_type walks the supported DynamoDB types (null, boolean, number, string, binary, sets, map, list). If the value matches none of them, it raises TypeError with the unsupported type and value. This protects the serializer from emitting an attribute DynamoDB would reject server-side.","triggerScenarios":"Putting a custom class instance, a set of mixed-type values, a frozenset, a datetime (without str conversion), or a tuple into an item to be put_item/update_item; using a Type that the serializer does not recognize.","commonSituations":"Passing datetime.datetime or datetime.date objects (boto3 has no automatic conversion); using set of Decimals mixed with ints (which becomes a non-uniform set); storing a custom dataclass object.","solutions":["Convert datetime/date to ISO 8601 strings, custom objects to dict/list, and tuples to lists before putting the item.","Ensure sets are homogeneous (all str, all Decimal, all bytes).","Run TypeSerializer().serialize(value) on a sample during development to catch unsupported types early."],"exampleFix":"# before\nitem = {'when': datetime.now(timezone.utc), 'tags': {'a', 1}}\ntable.put_item(Item=item)\n# after\nfrom decimal import Decimal\nitem = {\n    'when': datetime.now(timezone.utc).isoformat(),\n    'tags': {'a', 'b'},\n    'count': Decimal('1'),\n}\ntable.put_item(Item=item)","handlingStrategy":"validation","validationCode":"ALLOWED = (type(None), bool, int, str, bytes, bytearray, dict, list, set)\ndef clean_item(item):\n    for k, v in item.items():\n        assert isinstance(v, ALLOWED) or hasattr(v, '__dict__') is False, \\\n            f'Unsupported value type for {k!r}: {type(v).__name__}'\n    # convert datetimes, sets homogeneous, etc.\n    return item","typeGuard":"import datetime\nfrom decimal import Decimal\ndef is_serializable(v) -> bool:\n    if isinstance(v, (str, int, bool, bytes, bytearray, type(None), Decimal)):\n        return True\n    if isinstance(v, datetime.datetime):\n        return False  # must convert\n    return False","tryCatchPattern":"from botocore.exceptions import ClientError\ntry:\n    table.put_item(Item=item)\nexcept TypeError as e:  # local serialization error before request\n    item = {k: (v.isoformat() if hasattr(v, 'isoformat') else v) for k, v in item.items()}\n    table.put_item(Item=item)","preventionTips":["Convert datetime/date to ISO strings before storage.","Keep sets homogeneous.","Pre-serialize custom objects to dict/list."],"tags":["dynamodb","types","serialization","boto3"],"backgroundTag":null,"analyzedSha":"6e10b029c1326a437932a8b24f38af69fd986e15","analyzedAt":"2026-08-11T20:52:47.213Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}