simonrob / email-oauth2-proxy

An IMAP/POP/SMTP proxy that transparently adds OAuth 2.0 authentication for email clients that don't support this method.
Apache License 2.0
785 stars 84 forks source link

AttributeError: 'Window' object has no attribute 'loaded' #242

Closed wtcline-intc closed 3 months ago

wtcline-intc commented 4 months ago

Heads up: The latest release of email-oauth2-proxy on the upcoming Ubuntu LTS release (24.04) throws the following error:

2024-04-24 18:28:38: Accepting new connection from 127.0.0.1:38994 to SMTP server at 127.0.0.1:1587 (unsecured) proxying REDACTED (STARTTLS)
2024-04-24 18:28:41: Authorisation request received for REDACTED (interactive mode)
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pystray/_base.py", line 324, in inner
    callback(self)
  File "/usr/lib/python3/dist-packages/pystray/_base.py", line 449, in __call__
    return self._action(icon, self)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/REDACTED/./emailproxy.py", line 2812, in authorise_account
    self.create_authorisation_window(request)
  File "/home/REDACTED/REDACTED/./emailproxy.py", line 2842, in create_authorisation_window
    authorisation_window.loaded += self.authorisation_window_loaded
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Window' object has no attribute 'loaded'

I've looked into the error and it appears to be due to an improperly packaged dependency, python3-webview, reporting its module version as 0.0.0. This does not appear to be a bug in email-oauth2-proxy. I've filed a bug report against the python-pywebview package in Ubuntu.

simonrob commented 4 months ago

Thanks for reporting this. I suppose it is partly the proxy's fault for trying to preserve backwards compatibility (this wouldn't happen if it just assumed the latest version of pywebview), but it's also true that the python-pywebview wrapper shouldn't be reporting 0.0.0.

Depending on how long it takes to resolve, if needed you could also work around it by changing these lines to something like the following:

-        if pkg_resources.parse_version(
-                pkg_resources.get_distribution('pywebview').version) < pkg_resources.parse_version('3.6'):
+        pywebview_version = pkg_resources.parse_version(pkg_resources.get_distribution('pywebview').version)
+        if pkg_resources.parse_version('0') < pywebview_version < pkg_resources.parse_version('3.6'):

I had a quick look at pywebview itself too to see why this might be happening – the cause is probably that the project switched to dynamic versioning last year, and the Ubuntu package isn't picking this up.

wtcline-intc commented 4 months ago

I had a quick look at pywebview itself too to see why this might be happening – the cause is probably that the project switched to dynamic versioning last year, and the Ubuntu package isn't picking this up.

Agreed. In testing I was able to manually patch the version in, re-generate and re-install the package, and then email-oauth2-proxy worked as expected, but I'm not sure that's the correct way to do it since it'd involve manually updating the patched-in version number on every package update.

simonrob commented 3 months ago

It looks like the upstream bug has now been fixed, so I'll close this issue. Feel free to reopen if there is still a problem.

wtcline-intc commented 3 months ago

The bug was fixed in Oracular (unreleased), but has not yet been backported to Noble (Ubuntu 24.04 LTS). Users will still run into this issue on Noble until the package is Stable Release Updated (SRU'd) to Noble. Up to you whether you want the additional visibility from this issue being open.

simonrob commented 3 months ago

Thanks for clarifying. In that case, I'll just add the fix in the proxy itself to avoid any further issues.

wtcline-intc commented 2 months ago

Confirming that 9343592 fixes the issue!