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

ValueError: spooler callable dictionary must contains only bytes #492

Closed
flortsch opened this issue Nov 4, 2018 · 6 comments
Closed

ValueError: spooler callable dictionary must contains only bytes #492

flortsch opened this issue Nov 4, 2018 · 6 comments

Comments

@flortsch
Copy link
Contributor

flortsch commented Nov 4, 2018

Hello,
I was running Isso 0.10.6 on my server and updated to the latest release (0.11.1).
Now, the mail notification does not work anymore when someone creates a new comment on my site.

I am getting the following error message:
ValueError: spooler callable dictionary must contains only bytes

I uploaded an attachement with the traceback to this issue.
When I downgrade back to version 0.10.6, it works again.
I am running Isso installed via pip in a virtualenv with uWSGI.

isso.log

@vincentbernat
Copy link
Contributor

Could you try to apply the following patch:

diff --git a/isso/ext/notifications.py b/isso/ext/notifications.py
index 7d62d72c2b34..8115516bdbeb 100644
--- a/isso/ext/notifications.py
+++ b/isso/ext/notifications.py
@@ -91,7 +91,8 @@ class SMTP(object):
             def spooler(args):
                 try:
                     self._sendmail(args[b"subject"].decode("utf-8"),
-                                   args["body"].decode("utf-8"))
+                                   args[b"body"].decode("utf-8"),
+                                   args[b"to"].decode("utf-8"))
                 except smtplib.SMTPConnectError:
                     return uwsgi.SPOOL_RETRY
                 else:
@@ -173,17 +174,17 @@ class SMTP(object):
                     notified.append(email)
 
     def sendmail(self, subject, body, thread, comment, to=None):
+        to = to or self.conf.get("to")
         if uwsgi:
             uwsgi.spool({b"subject": subject.encode("utf-8"),
                          b"body": body.encode("utf-8"),
-                         b"to": to})
+                         b"to": to.encode("utf-8")})
         else:
             start_new_thread(self._retry, (subject, body, to))
 
-    def _sendmail(self, subject, body, to=None):
+    def _sendmail(self, subject, body, to_addr):
 
         from_addr = self.conf.get("from")
-        to_addr = to or self.conf.get("to")
 
         msg = MIMEText(body, 'plain', 'utf-8')
         msg['From'] = from_addr

@flortsch
Copy link
Contributor Author

flortsch commented Nov 5, 2018

I directly applied your patch to the 0.11.1 release installed on my server.
Tell me, if I should run git master and apply the patch there instead.

Now, I am getting a different error when creating a new comment.
This time the comment is created and queued for moderation (which was not the case before I applied the patch).
But the notification mail still can't be sent out.
I receive the following error:

uwsgi[9358]: Traceback (most recent call last):
uwsgi[9358]:   File "/opt/isso/env/lib/python3.5/site-packages/isso/ext/notifications.py", line 94, in spooler
uwsgi[9358]:     args[b"body"].decode("utf-8"),
uwsgi[9358]: KeyError: b'body'

@vincentbernat
Copy link
Contributor

On top of 0.11.1 should be fine. I am a bit lost why it was previously args["body"] instead of args[b"body"] while it is args[b"subject"]. But, try to change b"body" to "body" in the line where you have the error. Maybe it will be the same problem for b"to".

@flortsch
Copy link
Contributor Author

flortsch commented Nov 5, 2018

Okay, so I edited line 94 in notifications.py and changed args[b"body"] back to args["body"] after applying your patch. Now, the mail notifications are working again, no more error messages. Thank you very much :)

Should I create a PR, so this issue gets fixed?

@vincentbernat
Copy link
Contributor

Yes, you can open a PR.

@flortsch
Copy link
Contributor Author

flortsch commented Nov 6, 2018

Fixed with PR #495

@flortsch flortsch closed this as completed Nov 6, 2018
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