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

Add support for forgotten messages #124

Open
hoh opened this issue Dec 13, 2022 · 1 comment
Open

Add support for forgotten messages #124

hoh opened this issue Dec 13, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@hoh
Copy link
Member

hoh commented Dec 13, 2022

This issue is between aleph-message and aleph-client.

Querying a message using get_message(item_hash) raises the exception MessageNotFoundError if the message has been forgotten. This is not clear to users since the message is found and does exist, but has been forgotten.

When using get_messages(hashes=[item_hash], ignore_invalid_messages=False), a mapping error appears from aleph-message, indicating that the item_content field cannot be parsed (obviously, since it has been deleted when forgetting the message).

Traceback (most recent call last):
  File "/app/extra/plugins/python/helpers/pydev/pydevconsole.py", line 364, in runcode
    coro = func()
  File "<input>", line 1, in <module>
  File "/home/sepal/Repos/Aleph.im/aleph-client/src/aleph_client/synchronous.py", line 55, in get_message
    return wrap_async(asynchronous.get_message)(
  File "/home/sepal/Repos/Aleph.im/aleph-client/src/aleph_client/synchronous.py", line 22, in func_caller
    return loop.run_until_complete(func(*args, **kwargs))
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/sepal/Repos/Aleph.im/aleph-client/src/aleph_client/asynchronous.py", line 658, in get_message
    messages_response = await get_messages(
  File "/home/sepal/Repos/Aleph.im/aleph-client/src/aleph_client/asynchronous.py", line 630, in get_messages
    raise e
  File "/home/sepal/Repos/Aleph.im/aleph-client/src/aleph_client/asynchronous.py", line 626, in get_messages
    message = Message(**message_raw)
  File "/opt/venv/aleph-client/lib/python3.10/site-packages/aleph_message/models/__init__.py", line 388, in Message
    return message_class(**message_dict)
  File "pydantic/main.py", line 339, in pydantic.main.BaseModel.__init__
  File "pydantic/main.py", line 1056, in pydantic.main.validate_model
  File "pydantic/fields.py", line 871, in pydantic.fields.ModelField.validate
  File "pydantic/fields.py", line 1121, in pydantic.fields.ModelField._apply_validators
  File "pydantic/class_validators.py", line 282, in pydantic.class_validators._generic_validator_cls.lambda4
  File "/opt/venv/aleph-client/lib/python3.10/site-packages/aleph_message/models/__init__.py", line 290, in check_item_hash
    item_content: str = values["item_content"]
KeyError: 'item_content'

We should have a way to make get_message(item_hash) either return an object of class ForgottenMessage, or raise an exception ForgottenMessageError to explicitly inform the user that the message requested has been forgotten.

@BjrInt BjrInt self-assigned this Dec 16, 2022
@BjrInt BjrInt linked a pull request Dec 20, 2022 that will close this issue
4 tasks
@MHHukiewitz MHHukiewitz added the bug Something isn't working label Jan 2, 2023
@odesenfans
Copy link
Contributor

The plan is to stop publishing forgotten messages in the messages endpoint, it just doesn't make sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants