boto/boto3 · error · TypeError
Unsupported type "{type(value)}" for value "{value}"
Error message
Unsupported type "{type(value)}" for value "{value}" What it means
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.
Source
Thrown at boto3/dynamodb/types.py:153
elif self._is_type_set(value, self._is_number):
dynamodb_type = NUMBER_SET
elif self._is_type_set(value, self._is_string):
dynamodb_type = STRING_SET
elif self._is_type_set(value, self._is_binary):
dynamodb_type = BINARY_SET
elif self._is_map(value):
dynamodb_type = MAP
elif self._is_listlike(value):
dynamodb_type = LIST
else:
msg = f'Unsupported type "{type(value)}" for value "{value}"'
raise TypeError(msg)
return dynamodb_type
def _is_null(self, value):
if value is None:
return True
return False
def _is_boolean(self, value):
if isinstance(value, bool):
return True
return False
def _is_number(self, value):
if isinstance(value, (int, Decimal)):
return True
elif isinstance(value, float):
raise TypeError(View on GitHub (pinned to c7b4afac23)
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.
Example fix
# before
from datetime import datetime
table.put_item(Item={'ts': datetime.now()})
# after
table.put_item(Item={'ts': datetime.now().isoformat()}) Defensive patterns
Strategy: validation
Validate before calling
from datetime import date, datetime
from decimal import Decimal
def normalize_for_dynamodb(value):
if isinstance(value, (datetime, date)):
return value.isoformat()
if isinstance(value, float):
return Decimal(str(value))
if hasattr(value, '__dict__') and not isinstance(value, (str, bytes, bytearray)):
return {k: normalize_for_dynamodb(v) for k, v in vars(value).items()}
return value
def normalize_item(item):
return {k: normalize_for_dynamodb(v) for k, v in item.items()} Type guard
from decimal import Decimal
from boto3.dynamodb.types import Binary
def is_dynamodb_supported(v) -> bool:
return isinstance(v, (type(None), bool, int, Decimal, str, bytes, bytearray, Binary, list, tuple, dict, set)) Try / catch
try:
table.put_item(Item=item)
except TypeError as e:
if 'Unsupported type' in str(e):
item = normalize_item(item)
table.put_item(Item=item)
else:
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Value must be of the following types: {types}
- Float types are not supported. Use Decimal types instead.
- Infinity and NaN not supported
- Value must be a nonempty dictionary whose key is a valid dyn
- Dynamodb type {dynamodb_type} is not supported
AI-assisted analysis of boto/boto3@c7b4afac23 (2026-08-04).
Data as JSON: /data/errors/fdadafabeb86747f.json.
Report an issue: GitHub.