Closed ghost closed 1 year ago
This might be material for a separate ticket, but while filtering out the CartCreated
messages I found this library also chokes with InventoryEntityCreated
messages:
Traceback (most recent call last):
File "messages.py", line 44, in get_messages
tptest = sdk_client.messages.query(where=['type != "CartCreated"'])
File "/usr/local/lib/python3.7/site-packages/commercetools/services/messages.py", line 63, in query
schema_cls=MessagePagedQueryResponseSchema,
File "/usr/local/lib/python3.7/site-packages/commercetools/client.py", line 122, in _get
return schema_cls().load(response.json())
File "/usr/local/lib/python3.7/site-packages/marshmallow/schema.py", line 728, in load
data, many=many, partial=partial, unknown=unknown, postprocess=True
File "/usr/local/lib/python3.7/site-packages/marshmallow/schema.py", line 866, in _do_load
unknown=unknown,
File "/usr/local/lib/python3.7/site-packages/marshmallow/schema.py", line 674, in _deserialize
index=index,
File "/usr/local/lib/python3.7/site-packages/marshmallow/schema.py", line 496, in _call_and_store
value = getter_func(data)
File "/usr/local/lib/python3.7/site-packages/marshmallow/schema.py", line 667, in <lambda>
val, field_name, data, **d_kwargs
File "/usr/local/lib/python3.7/site-packages/marshmallow/fields.py", line 356, in deserialize
output = self._deserialize(value, attr, data, **kwargs)
File "/usr/local/lib/python3.7/site-packages/marshmallow/fields.py", line 728, in _deserialize
result.append(self.inner.deserialize(each, **kwargs))
File "/usr/local/lib/python3.7/site-packages/marshmallow/fields.py", line 356, in deserialize
output = self._deserialize(value, attr, data, **kwargs)
File "/usr/local/lib/python3.7/site-packages/commercetools/helpers.py", line 222, in _deserialize
return self._load(value, data, **kwargs)
File "/usr/local/lib/python3.7/site-packages/commercetools/helpers.py", line 215, in _load
valid_data = schema.load(value, unknown=self.unknown)
File "/usr/local/lib/python3.7/site-packages/marshmallow/schema.py", line 728, in load
data, many=many, partial=partial, unknown=unknown, postprocess=True
File "/usr/local/lib/python3.7/site-packages/marshmallow/schema.py", line 866, in _do_load
unknown=unknown,
File "/usr/local/lib/python3.7/site-packages/marshmallow/schema.py", line 674, in _deserialize
index=index,
File "/usr/local/lib/python3.7/site-packages/marshmallow/schema.py", line 496, in _call_and_store
value = getter_func(data)
File "/usr/local/lib/python3.7/site-packages/marshmallow/schema.py", line 667, in <lambda>
val, field_name, data, **d_kwargs
File "/usr/local/lib/python3.7/site-packages/marshmallow/fields.py", line 356, in deserialize
output = self._deserialize(value, attr, data, **kwargs)
File "/usr/local/lib/python3.7/site-packages/marshmallow/fields.py", line 611, in _deserialize
return self._load(value, data, partial=partial)
File "/usr/local/lib/python3.7/site-packages/marshmallow/fields.py", line 594, in _load
valid_data = self.schema.load(value, unknown=self.unknown, partial=partial)
File "/usr/local/lib/python3.7/site-packages/marshmallow/schema.py", line 728, in load
data, many=many, partial=partial, unknown=unknown, postprocess=True
File "/usr/local/lib/python3.7/site-packages/marshmallow/schema.py", line 902, in _do_load
partial=partial,
File "/usr/local/lib/python3.7/site-packages/marshmallow/schema.py", line 1101, in _invoke_load_processors
partial=partial,
File "/usr/local/lib/python3.7/site-packages/marshmallow/schema.py", line 1227, in _invoke_processors
data = processor(data, many=many, **kwargs)
File "/usr/local/lib/python3.7/site-packages/commercetools/_schemas/_inventory.py", line 152, in post_load
return types.InventoryEntry(**data)
TypeError: __init__() missing 5 required keyword-only arguments: 'id', 'version', 'created_at', 'last_modified_at', and 'available_quantity'
This is the JSON that caused this crash, I guess because inventory.InventoryEntrySchema
is incorrectly used in InventoryEntryCreatedMessageSchema
:
{
"id": "fe7ce4e8-db92-4fce-acd1-a56c835d51de",
"version": 1,
"sequenceNumber": 1,
"resource": {
"typeId": "inventory-entry",
"id": "bf9dc9be-2a24-4d3f-941a-adbcc6ea02e8"
},
"resourceVersion": 1,
"resourceUserProvidedIdentifiers": {
"sku": "test-0001"
},
"type": "InventoryEntryCreated",
"inventoryEntry": {
"type": "InventoryEntryCreated",
"inventoryEntryId": "bf9dc9be-2a24-4d3f-941a-adbcc6ea02e8",
"sku": "test-0001",
"quantityOnStock": 100000,
"messageId": {
"id": "fe7ce4e8-db92-4fce-acd1-a56c835d51de",
"sequenceNumber": 1
}
},
"createdAt": "2021-03-08T17:58:43.341Z",
"lastModifiedAt": "2021-03-08T17:58:43.341Z",
"lastModifiedBy": {
"isPlatformClient": true,
"user": {
"typeId": "user",
"id": "4be59133-dea6-4d4d-a49c-90a2204d6d1f"
}
},
"createdBy": {
"isPlatformClient": true,
"user": {
"typeId": "user",
"id": "4be59133-dea6-4d4d-a49c-90a2204d6d1f"
}
}
}
hi @rbou-globant , I assume this is with version 13? Can you give 14.0.0b2 a try? It still beta although we should be able to release it this week. The codebase is in version 14 generated using a new code generator via the commerctools rmf-codegen project. It should fix numerous issues and includes support for the import-api and machinelearning api
I tried version 14.0.0b2 and I'm still getting the first error (ValueError: Could not find discriminator schema CartCreated for field 'results'
), but not the second one.
Weird, could you create a unittest for this in the existing codebase? that makes it easy for us to spot the issue
Should be fixed in latest release, see https://pypi.org/project/commercetools/
Let us know if that is not the case
Hi! While calling
Client.messages.query
I'm noticing that theCartCreated
schema is missing: