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

Improve validation of configuration, especially the homeserver URL #28

Open
ojaksch opened this issue Aug 6, 2024 · 4 comments
Open

Comments

@ojaksch
Copy link

ojaksch commented Aug 6, 2024

I'm using OctoPrint with a x86_64 Debian Bookworm based PC. Everything is working great for years. But I'm sure since I upgraded to Bookworm end of March 2024 your plugin isn't working anymore, maybe as a result of Python 3.11.

That's not particularly bad but the feature of being notified by Matrix was a nice option and (if the culprit is Python 3.11) this issue will need attention in near future for others using OctoPi and other OS'es using a more modern Python version.

Server Address is: matrix.example.org
Room Address is: #daheim:matrix.example.org
(example.org is exemplary, of course)

2024-08-06 10:25:32,136 - octoprint.plugins.matrix_notifier - INFO - Got event Startup with payload {}
2024-08-06 10:25:32,149 - octoprint.plugin - ERROR - Error while calling plugin matrix_notifier
Traceback (most recent call last):
  File "/home/pi/OctoPrint/lib/python3.11/site-packages/octoprint/plugin/__init__.py", line 275, in call_plugin
    result = getattr(plugin, method)(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/OctoPrint/lib/python3.11/site-packages/octoprint/util/__init__.py", line 1686, in wrapper
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/home/pi/OctoPrint/lib/python3.11/site-packages/octoprint_matrix_notifier/plugin.py", line 226, in on_event
    self.client.room_send_markdown_message(self.room_id, message)
                                           ^^^^^^^^^^^^
  File "/home/pi/OctoPrint/lib/python3.11/site-packages/octoprint_matrix_notifier/plugin.py", line 267, in room_id
    room_id = self.client.room_resolve_alias(room)["room_id"]
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/OctoPrint/lib/python3.11/site-packages/octoprint_matrix_notifier/matrix.py", line 52, in room_resolve_alias
    return self._send(method, path)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/OctoPrint/lib/python3.11/site-packages/octoprint_matrix_notifier/matrix.py", line 42, in _send
    req = Request(url, data=data, headers=headers, method=method)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 322, in __init__
    self.full_url = url
    ^^^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 348, in full_url
    self._parse()
  File "/usr/lib/python3.11/urllib/request.py", line 377, in _parse
    raise ValueError("unknown url type: %r" % self.full_url)
ValueError: unknown url type: '/_matrix/client/r0/directory/room/%23daheim%3Amatrix.example.org'
@Cadair
Copy link
Owner

Cadair commented Oct 1, 2024

I would guess that your homeserver base URL either isn't configured or is not configured correctly, that error seems to be saying that there isn't a http etc at the start of the URL?

@ojaksch
Copy link
Author

ojaksch commented Oct 1, 2024

Funny! I'm having to do some printings today so this is good a good opportunity to address this.
I prefixed the URL with https:// and added the needed port and voila, it is working again. But even funnier that there is a http forwarding rule for that and that had worked in the past. Never changed synapse (the server part).

Anyways, thanks for listening and to pointing me to the right correction.

@ojaksch ojaksch closed this as completed Oct 1, 2024
@Cadair
Copy link
Owner

Cadair commented Oct 1, 2024

Glad it's working, this is an insane failure mode for invalid config, so I will reopen this to improve validation

@Cadair Cadair reopened this Oct 1, 2024
@Cadair Cadair changed the title "Error while calling plugin matrix_notifier" Improve validation of configuration, especially the homeserver URL Oct 1, 2024
@ojaksch
Copy link
Author

ojaksch commented Oct 1, 2024

...and a "test now" button would be great :)

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