boto/boto3 · error · TypeError

Unsupported type " " for value

Error message

Unsupported type "{type(value)}" for value "{value}"

What it means

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.

Solutions

  1. Convert datetime/date to ISO 8601 strings, custom objects to dict/list, and tuples to lists before putting the item.
  2. Ensure sets are homogeneous (all str, all Decimal, all bytes).
  3. Run TypeSerializer().serialize(value) on a sample during development to catch unsupported types early.

Example fix

# before
item = {'when': datetime.now(timezone.utc), 'tags': {'a', 1}}
table.put_item(Item=item)
# after
from decimal import Decimal
item = {
    'when': datetime.now(timezone.utc).isoformat(),
    'tags': {'a', 'b'},
    'count': Decimal('1'),
}
table.put_item(Item=item)
Defensive patterns

Strategy: validation

Validate before calling

ALLOWED = (type(None), bool, int, str, bytes, bytearray, dict, list, set)
def clean_item(item):
    for k, v in item.items():
        assert isinstance(v, ALLOWED) or hasattr(v, '__dict__') is False, \
            f'Unsupported value type for {k!r}: {type(v).__name__}'
    # convert datetimes, sets homogeneous, etc.
    return item

Type guard

import datetime
from decimal import Decimal
def is_serializable(v) -> bool:
    if isinstance(v, (str, int, bool, bytes, bytearray, type(None), Decimal)):
        return True
    if isinstance(v, datetime.datetime):
        return False  # must convert
    return False

Try / catch

from botocore.exceptions import ClientError
try:
    table.put_item(Item=item)
except TypeError as e:  # local serialization error before request
    item = {k: (v.isoformat() if hasattr(v, 'isoformat') else v) for k, v in item.items()}
    table.put_item(Item=item)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of boto/boto3@6e10b029c1 (2026-08-11). Data as JSON: /api/errors/fdadafabeb86747f. Report an issue: GitHub.

Appendix: 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 6e10b029c1)