iFargle / headscale-webui

A simple Headscale web UI for small-scale deployments.
Other
619 stars 56 forks source link

Exception when opening pages that loads preauthkeys from Headscale #109

Open maddie opened 1 year ago

maddie commented 1 year ago

Here's the exception:

[2023-06-12 17:50:55,478] ERROR in app: Exception on /overview [GET]
Traceback (most recent call last):
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/server.py", line 114, in decorated
    return view_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/server.py", line 155, in overview_page
    render_page       = renderer.render_overview(),
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/renderer.py", line 82, in render_overview
    expiration_parse = parser.parse(key["expiration"])
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/dateutil/parser/_parser.py", line 1368, in parse
    return DEFAULTPARSER.parse(timestr, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/dateutil/parser/_parser.py", line 640, in parse
    res, skipped_tokens = self._parse(timestr, **kwargs)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/dateutil/parser/_parser.py", line 719, in _parse
    l = _timelex.split(timestr)         # Splits the timestr into tokens
        ^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/dateutil/parser/_parser.py", line 201, in split
    return list(cls(s))
                ^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/dateutil/parser/_parser.py", line 69, in __init__
    raise TypeError('Parser must be a string or character stream, not '
TypeError: Parser must be a string or character stream, not NoneType

I suspect that the reason is I have a pre-auth key without an expiration date:

ID | Key                                              | Reusable | Ephemeral | Used  | Expiration          | Created             | Tags
2  | e92765cffef35ad25f16xxxxxxxxxxx0262823d17047f456 | true     | false     | false | 2021-10-09 03:59:12 | 2021-10-09 03:58:49 |
1  | 85cdd30dfb5221890179xxxxxxxxxxxafdef3e161e339d45 | true     | false     | true  | -                   | 2021-08-02 15:23:22 |
iFargle commented 1 year ago

Are these pre-auth keys or headscale API keys? I think the error is with an API key that doesn't expire maybe?
Do you get an error on the Settings page when testing the key?

maddie commented 1 year ago

I think it's preauthkeys, I've only generated my first API key when installing the webui.

Key testing works fine, Routes and Machines page works too.

maddie commented 1 year ago

After manually UPDATE-ing the row with null expiration field in postgres, it works now.

It seems the newer Headscale doesn't allow creating pre-auth keys without expiration anymore, the database I'm using was created by a very ancient version of Headscale, so maybe that's why.