Skip to content

Improve validation of configuration, especially the homeserver URL #28

@ojaksch

Description

@ojaksch

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions