boto/boto3 · error · TypeError
Dynamodb type {dynamodb_type} is not supported
Error message
Dynamodb type {dynamodb_type} is not supported What it means
Raised by TypeDeserializer.deserialize when the input dict's key does not correspond to a valid DynamoDB type. The deserializer looks up a method named _deserialize_<key>; if getattr fails (AttributeError), it converts the failure into a TypeError naming the unsupported type. Valid keys are NULL, BOOL, N, S, B, NS, SS, BS, L, M (case-sensitive as defined by the module constants).
Source
Thrown at boto3/dynamodb/types.py:279
{'BS': [bytes]} set([bytes])
{'L': list} list
{'M': dict} dict
:returns: The pythonic value of the DynamoDB type.
"""
if not value:
raise TypeError(
'Value must be a nonempty dictionary whose key '
'is a valid dynamodb type.'
)
dynamodb_type = list(value.keys())[0]
try:
deserializer = getattr(
self, f'_deserialize_{dynamodb_type}'.lower()
)
except AttributeError:
raise TypeError(f'Dynamodb type {dynamodb_type} is not supported')
return deserializer(value[dynamodb_type])
def _deserialize_null(self, value):
return None
def _deserialize_bool(self, value):
return value
def _deserialize_n(self, value):
return DYNAMODB_CONTEXT.create_decimal(value)
def _deserialize_s(self, value):
return value
def _deserialize_b(self, value):
return Binary(value)
def _deserialize_ns(self, value):View on GitHub (pinned to c7b4afac23)
Solutions
- Use only the canonical uppercase keys: S, N, B, SS, NS, BS, BOOL, NULL, L, M.
- If consuming external data, map/normalize keys to DynamoDB type tags before deserializing.
- Use TypeSerializer to produce values so keys are always correct.
Example fix
# before
from boto3.dynamodb.types import TypeDeserializer
TypeDeserializer().deserialize({'n': '42'}) # lowercase key
# after
TypeDeserializer().deserialize({'N': '42'}) # correct uppercase key Defensive patterns
Strategy: validation
Validate before calling
from boto3.dynamodb.types import (
STRING, NUMBER, BINARY, STRING_SET, NUMBER_SET, BINARY_SET,
NULL, BOOLEAN, MAP, LIST,
)
VALID_TYPES = {STRING, NUMBER, BINARY, STRING_SET, NUMBER_SET, BINARY_SET, NULL, BOOLEAN, MAP, LIST}
def validate_dynamodb_value(v):
if not v or not isinstance(v, dict) or len(v) != 1:
raise ValueError(f'Expected single-key DynamoDB dict, got {v!r}')
key = next(iter(v))
if key not in VALID_TYPES:
raise ValueError(f'Invalid DynamoDB type key: {key!r}. Valid: {VALID_TYPES}')
return v Type guard
def is_valid_dynamodb_typed_dict(v) -> bool:
valid = {'S','N','B','SS','NS','BS','BOOL','NULL','L','M'}
return isinstance(v, dict) and len(v) == 1 and next(iter(v)) in valid Prevention
- Prefer TypeSerializer over hand-building typed dicts.
- Validate the single key against the canonical uppercase set before deserialize.
- Document the exact type tags when interfacing with external producers.
When it happens
Trigger: TypeDeserializer().deserialize({'XX': 'val'}) — 'XX' is not a DynamoDB type. Also {'n': '1'} (lowercase), {'Number': '1'}, or any misspelled/wrong-case key. This can occur when manually constructing type-tagged dicts or receiving data from a non-DynamoDB source.
Common situations: Hand-building DynamoDB-format dicts with wrong key casing; consuming a REST API that uses different type tags; version mismatch where a custom serializer emits non-standard keys.
Related errors
- Value must be a nonempty dictionary whose key is a valid dyn
- Value must be of the following types: {types}
- Unsupported type "{type(value)}" for value "{value}"
- Float types are not supported. Use Decimal types instead.
- Infinity and NaN not supported
AI-assisted analysis of boto/boto3@c7b4afac23 (2026-08-04).
Data as JSON: /data/errors/065fa202776e8172.json.
Report an issue: GitHub.