modoboa / modoboa-amavis

The amavis frontend of Modoboa
https://modoboa.org
MIT License
23 stars 16 forks source link

Cannot Release Emails #122

Closed myousuffazal closed 4 years ago

myousuffazal commented 4 years ago

Cannot release any email from the Quarantine Management

DoesNotExist at /quarantine/release/wNxCxiq8ySp5/ Msgs matching query does not exist.

Traceback:

File "/srv/modoboa/env/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py" in get

  1. rel_obj = getattr(instance, self.cache_name)

    During handling of the above exception ('Msgrcpt' object has no attribute '_mail_cache'), another exception occurred:

File "/srv/modoboa/env/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner

  1. response = get_response(request)

File "/srv/modoboa/env/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response

  1. response = self.process_exception_by_middleware(e, request)

File "/srv/modoboa/env/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response

  1. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/lib/python3.6/contextlib.py" in inner

  1. return func(*args, **kwds)

File "/usr/lib/python3.6/contextlib.py" in inner

  1. return func(*args, **kwds)

File "/srv/modoboa/env/lib/python3.6/site-packages/modoboa_amavis/lib.py" in wrapped_f

  1. return f(request, *args, **kwargs)

File "/srv/modoboa/env/lib/python3.6/site-packages/modoboa_amavis/views.py" in release

  1. rcpt.mail.mail_id, rcpt.mail.secret_id, rcpt.rid.email

File "/srv/modoboa/env/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py" in get

  1. rel_obj = self.get_object(instance)

File "/srv/modoboa/env/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py" in get_object

  1. return qs.get(self.field.get_reverse_related_filter(instance))

File "/srv/modoboa/env/lib/python3.6/site-packages/django/db/models/query.py" in get

  1. self.model._meta.object_name
s256 commented 4 years ago

Probably duplicate of https://github.com/modoboa/modoboa-amavis/issues/102

myousuffazal commented 4 years ago

Yes, it seems like, but even there, there is no solution to the problem.

s256 commented 4 years ago

It's on the roadmap for the next release as I just saw. Hopefully it's coming soon :)

Just want to confirm that I get the same error:

Traceback (most recent call last):
  File "/srv/modoboa/env/lib/python3.7/site-packages/django/db/models/fields/related_descriptors.py", line 178, in __get__
    rel_obj = getattr(instance, self.cache_name)
AttributeError: 'Msgrcpt' object has no attribute '_mail_cache'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/modoboa/env/lib/python3.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/srv/modoboa/env/lib/python3.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/srv/modoboa/env/lib/python3.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python3.7/contextlib.py", line 74, in inner
    return func(*args, **kwds)
  File "/usr/lib/python3.7/contextlib.py", line 74, in inner
    return func(*args, **kwds)
  File "/srv/modoboa/env/lib/python3.7/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/srv/modoboa/env/lib/python3.7/site-packages/modoboa_amavis/views.py", line 430, in process
    return release(request, ids)
  File "/srv/modoboa/env/lib/python3.7/site-packages/modoboa_amavis/lib.py", line 49, in wrapped_f
    return f(request, *args, **kwargs)
  File "/srv/modoboa/env/lib/python3.7/site-packages/modoboa_amavis/views.py", line 313, in release
    rcpt.mail.mail_id, rcpt.mail.secret_id, rcpt.rid.email
  File "/srv/modoboa/env/lib/python3.7/site-packages/django/db/models/fields/related_descriptors.py", line 184, in __get__
    rel_obj = self.get_object(instance)
  File "/srv/modoboa/env/lib/python3.7/site-packages/django/db/models/fields/related_descriptors.py", line 159, in get_object
    return qs.get(self.field.get_reverse_related_filter(instance))
  File "/srv/modoboa/env/lib/python3.7/site-packages/django/db/models/query.py", line 380, in get
    self.model._meta.object_name
modoboa_amavis.models.DoesNotExist: Msgs matching query does not exist.
[29/Apr/2020 00:11:04] "POST /quarantine/process/ HTTP/1.0" 500 18647
s256 commented 4 years ago

Update: This behaves different with mysql. While running one server with mysql and one with postgres (both fresh installations for these tests) on the MYSQL Server I see this in the mail.log

amavis[9501]: (!!)policy_server FAILED: Invalid mail_id 'b'Zw-aSSDcDXNE'' at (eval 95) line 281, <GEN55> line 6.

While I there is no such message with the postgres setup. This simply strikes me like a type error where this is binary opposed to string. I just haven't figured out the part in the code to fix it.

myousuffazal commented 4 years ago

I am running it with postgres and it doesn't outputs any message in mail.log when I click Release.

myousuffazal commented 4 years ago

It must be an issue with parsing somewhere in the code, because I can easily mark that email as non-spam and it shows success for that, but for releasing it gives error. So for marking it not spam, it gets to access the database properly but for releasing it, it is causing error.

studioluminous commented 4 years ago

I have this issue as well on Ubuntu 18.04 running Modoboa 1.15.0 with mysql and modoboa-amavis 1.3.0. They can be deleted, marked as spam and everything other than being released.

tonioo commented 4 years ago

Guys, I've just pushed a fix tested on python 3.5.3 and postgres which allows superadmins to release messages. Can you tell me what is your setup?

studioluminous commented 4 years ago

I’m running mysql(mariadb) not postgres and modoboa 1.15.0., Python is 3.6.9.

On May 12, 2020, at 12:25 PM, Antoine Nguyen notifications@github.com wrote:

Guys, I've just pushed a fix tested on python 3.5.3 and postgres which allows superadmins to release messages. Can you tell me what is your setup?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/modoboa/modoboa-amavis/issues/122#issuecomment-627543973, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGXMNW3QP2FEVIMLWB3HE2DRRGPBLANCNFSM4MMG24OA.

tonioo commented 4 years ago

@studioluminous could you try the fix on your installation?

studioluminous commented 4 years ago

Sure @tonioo how do I go about getting the fix?

tonioo commented 4 years ago

@studioluminous you can retrieve a patch corresponding to the referenced commit or you can install the development version of this plugin using pip. For example (if you used the installer):

su - modoboa
bash
source env/bin/activate
pip install -e git+https://github.com/modoboa/modoboa-amavis#egg=modoboa-amavis

And then reload uwsgi as root.

studioluminous commented 4 years ago

Thanks @tonioo, that works just fine. I didn't try it on a domain admin or user level but for a superadmin it works. I do notice that if I try and batch release, it still doesn't work. If I do them individually then it's fine but a bit cumbersome. I also tried batch deleting and that's an issue as well. Individual actions work but not if I have more than one message checked.

tonioo commented 4 years ago

@studioluminous indeed batch releasing do not seem to work but I can batch delete... (at least using postgres, I'm testing on the official modoboa demo). Do you have more information?

studioluminous commented 4 years ago

@tonioo Sure, I'm used the Modoboa installer but I chose mysql so I'm running Maria DB. I just updated to 1.15 and all the extensions to their latest version. I've not modified Modoboa or added any customizations other than a logo for the login screen. I've not added any extensions other than what came with the installer. I'm running Ubuntu 18.04 on a VPS with plenty of memory and storage. My packages are all updated to the latest versions as of yesterday. I just updated PIP and made sure my virtualenv is in Python 3.6.9. If you need any more information I'm happy to help.

tonioo commented 4 years ago

@studioluminous ok. And when you try to release more than one email, what happens?

studioluminous commented 4 years ago

Nothing. Everything just stays as it is. It prompts me through the browser if I’m sure I want to release or delete the selection and the I confirm and nothing happens. I refresh the window and all the emails are still there.

Jasha

On May 15, 2020, at 9:24 AM, Antoine Nguyen notifications@github.com wrote:

 @studioluminous ok. And when you try to release more than one email, what happens?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

tonioo commented 4 years ago

Can you open you javascript console and check the network tab? You should see requests returning with errors (400 or 500).

tonioo commented 4 years ago

@studioluminous I think I've fixed the issue. I pushed a new fix, can you test it please? (just git pull your local copy and reload uwsgi)

studioluminous commented 4 years ago

@tonioo Thanks and sorry I couldn't get back to you yesterday. I just tested it and it seems resolved for releasing and deleting. Thanks for all your help!

Pleskan commented 4 years ago

@tonioo Thanks for pointing me here. I've applied patch myself.