throws an error on invalid types when creating an entity
@@ -207,9 +207,12 @@ def _add_entity_properties(source):
properties = {}
+ to_send = dict(source) # shallow copy
+ to_send.pop("_metadata", None)
+
# set properties type for types we know if value has no type info.
# if value has type info, then set the type to value.type
- for name, value in source.items():
+ for name, value in to_send.items():
mtype = ''
if isinstance(value, Enum):
@@ -226,8 +229,11 @@ def _add_entity_properties(source):
mtype, value = conv(value.value)
else:
conv = _PYTHON_TO_ENTITY_CONVERSIONS.get(type(value))
- if conv is None or value is None:
- conv = _to_entity_none # something with this
+ if conv is None and value is not None:
+ raise TypeError(
+ _ERROR_TYPE_NOT_SUPPORTED.format(type(value)))
+ if value is None:
+ conv = _to_entity_none
mtype, value = conv(value)
