Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValidationError when listening to messages on aleph-sdk-python 0.6.0 #51

Open
MHHukiewitz opened this issue Mar 11, 2023 · 1 comment
Open

Comments

@MHHukiewitz
Copy link
Member

The following error occurs when I start listening to Aleph messages with AlephClient.watch_messaages():

ValidationError(model='AggregateMessage', errors=[{'loc': ('_id',), 'msg': 'value is not a valid dict', 'type': 'type_error.dict'}])>
Traceback (most recent call last):
  File "/home/mik/PycharmProjects/yourtrading-ai/fishnet-cod/src/fishnet_cod/local_executor.py", line 50, in main
    await listen()
  File "/home/mik/PycharmProjects/yourtrading-ai/fishnet-cod/src/fishnet_cod/local_executor.py", line 37, in listen
    async for message in aars_client.session.watch_messages(
  File "/home/mik/PycharmProjects/yourtrading-ai/fishnet-cod/.venv/lib/python3.9/site-packages/aleph/sdk/client.py", line 812, in watch_messages
    yield Message(**data)
  File "/home/mik/PycharmProjects/yourtrading-ai/fishnet-cod/.venv/lib/python3.9/site-packages/aleph_message/models/__init__.py", line 333, in Message
    return message_class(**message_dict)
  File "pydantic/main.py", line 342, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for AggregateMessage
_id
  value is not a valid dict (type=type_error.dict)

It seems there are sometimes messages with _id or id_ fields when querying api2.aleph.im

@odesenfans
Copy link
Contributor

The id_ field is a MongoDB ID and should never be shown, so that's a bug in the message API. I thought it was resolved. Anyway, it will never appear again with the new version so I wouldn't care too much about it.

The aggregate issue you mentioned is more problematic. Aggregates are supposed to be a key/value store. Some users post non-dict aggregates and these messages can be accepted on older pyaleph versions. I made the switch to enable this validation on the Postgres version, but it seems I was a bit trigger-happy with this change and I did not think about the messages currently stored on Mongo nodes. Here is the line that causes your problem in aleph-message.

We can revert it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants