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

Internal Server Error on /routes #69

Closed
ngreenwood6 opened this issue Apr 1, 2023 · 13 comments · Fixed by #71
Closed

Internal Server Error on /routes #69

ngreenwood6 opened this issue Apr 1, 2023 · 13 comments · Fixed by #71
Assignees
Labels
bug Something isn't working

Comments

@ngreenwood6
Copy link

It looks like the feature to view the routes was just added which is awesome. However, when I try to view the page it just gives an "Internal Server Error". The docker logs show the following:

[2023-04-01 01:59:28,796] ERROR in app: Exception on /routes [GET]
Traceback (most recent call last):
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 2528, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/server.py", line 131, in decorated
    return view_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/server.py", line 183, in routes_page
    render_page       = renderer.render_routes(),
                        ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/renderer.py", line 799, in render_routes
    if all_routes["routes"][int(route_id) - 1]["enabled"]: failover_display = failover_enabled
       ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
IndexError: list index out of range
@iFargle iFargle self-assigned this Apr 1, 2023
@iFargle iFargle added the bug Something isn't working label Apr 1, 2023
@iFargle
Copy link
Owner

iFargle commented Apr 1, 2023

Can you give me the output of the routes ls command on your Headscale servers?
headscale routes ls

@iFargle
Copy link
Owner

iFargle commented Apr 1, 2023

All my routes are ordered but I'm not sure it's the correct way to do it.. So I just take the route ID and subtract 1 for the index in the array. It's likely you have deleted routes or something so the index is "wrong"

@ngreenwood6
Copy link
Author

Yeah I definitely have been messing around and removed routes. Here is the output:

ID | Machine    | Prefix          | Advertised | Enabled | Primary
3  | alex-pc    | 0.0.0.0/0       | false      | false   | -      
4  | alex-pc    | ::/0            | false      | false   | -      
13 | dev-server | 192.168.1.0/24  | true       | true    | true   
18 |            | 192.168.99.0/24 | true       | false   | false  
19 |            | 192.168.99.0/24 | true       | false   | false  
20 |            | 192.168.99.0/24 | true       | false   | false  
21 |            | 192.168.99.0/24 | true       | false   | false  
22 | pfsense    | 192.168.96.0/19 | true       | true    | true   
23 |            | 0.0.0.0/0       | true       | true    | -      
24 |            | ::/0            | true       | true    | -    

@ngreenwood6
Copy link
Author

After looking at this I also noticed that by removing machines that I setup those routes on it didn't remove the routes. Shouldn't it be removing those routes when the machine is removed? I am not sure if this is a "UI" issue or an "API" issue. Maybe I should put this on the head scale repo?

@iFargle
Copy link
Owner

iFargle commented Apr 1, 2023 via email

@iFargle
Copy link
Owner

iFargle commented Apr 1, 2023 via email

@iFargle
Copy link
Owner

iFargle commented Apr 1, 2023

Actually that may have been an easier fix than I thought.
Can you pull ghcr.io/ifargle/headscale-webui:testing and give it a shot?
if this works I'll move it into main :)

@ngreenwood6
Copy link
Author

It looks like its still happening. I am getting the following:

[2023-04-01 20:45:02,295] INFO in renderer: Rendering Routes page
[2023-04-01 20:45:02,295] INFO in headscale: Getting routes
[2023-04-01 20:45:02,400] INFO in renderer: Found route 3 / machine: Alex-PC
[2023-04-01 20:45:02,400] INFO in renderer: Found route 4 / machine: Alex-PC
[2023-04-01 20:45:02,400] INFO in renderer: Found route 13 / machine: dev-server
[2023-04-01 20:45:02,400] INFO in renderer: Route id 18 has no machine associated. Skipping
[2023-04-01 20:45:02,400] INFO in renderer: Route id 19 has no machine associated. Skipping
[2023-04-01 20:45:02,400] INFO in renderer: Route id 20 has no machine associated. Skipping
[2023-04-01 20:45:02,400] INFO in renderer: Route id 21 has no machine associated. Skipping
[2023-04-01 20:45:02,400] INFO in renderer: Found route 22 / machine: pfSense
[2023-04-01 20:45:02,400] INFO in renderer: Route id 23 has no machine associated. Skipping
[2023-04-01 20:45:02,400] INFO in renderer: Route id 24 has no machine associated. Skipping
[2023-04-01 20:45:02,400] ERROR in app: Exception on /routes [GET]
Traceback (most recent call last):
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 2528, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/server.py", line 131, in decorated
    return view_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/server.py", line 183, in routes_page
    render_page       = renderer.render_routes(),
                        ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/renderer.py", line 808, in render_routes
    current_route_index = all_routes_id_list.index(route_id)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: '18' is not in list

@iFargle
Copy link
Owner

iFargle commented Apr 2, 2023

18 | | 192.168.99.0/24 | true | false | false
Let me do one more fix. This will still display empty routes but at least it won't error out :)

@iFargle
Copy link
Owner

iFargle commented Apr 2, 2023

(For now, you'll need to manually delete the routes through Headscale's CLI, my UI doesn't have a way of deleting routes, just enabling/disabling)

Try pulling a new build on testing. It should display now

@iFargle iFargle linked a pull request Apr 2, 2023 that will close this issue
@ngreenwood6
Copy link
Author

ngreenwood6 commented Apr 3, 2023

Just wanted to let you know on the latest the page is working. Thanks for the quick response.

@DrShurii
Copy link

WebUI Internal Server Error:

getting the below error :

headscale-webui | [2023-10-22 14:25:04,859] INFO in helper: All startup checks passed.
headscale-webui | [2023-10-22 14:25:04,860] ERROR in app: Exception on / [GET]
headscale-webui | Traceback (most recent call last):
headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/fernet.py", line 133, in _verify_signature
headscale-webui | h.verify(data[-32:])
headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/hmac.py", line 70, in verify
headscale-webui | ctx.verify(signature)
headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/hazmat/backends/openssl/hmac.py", line 84, in verify
headscale-webui | raise InvalidSignature("Signature did not match digest.")
headscale-webui | cryptography.exceptions.InvalidSignature: Signature did not match digest.
headscale-webui |
headscale-webui | During handling of the above exception, another exception occurred:
headscale-webui |
headscale-webui | Traceback (most recent call last):
headscale-webui | File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 2190, in wsgi_app
headscale-webui | response = self.full_dispatch_request()
headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
headscale-webui | File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1486, in full_dispatch_request
headscale-webui | rv = self.handle_user_exception(e)
headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
headscale-webui | File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1484, in full_dispatch_request
headscale-webui | rv = self.dispatch_request()
headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^
headscale-webui | File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1469, in dispatch_request
headscale-webui | return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
headscale-webui | File "/app/server.py", line 114, in decorated
headscale-webui | return view_func(*args, **kwargs)
headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^
headscale-webui | File "/app/server.py", line 141, in overview_page
headscale-webui | pass_checks = str(helper.load_checks())
headscale-webui | ^^^^^^^^^^^^^^^^^^^^
headscale-webui | File "/app/helper.py", line 301, in load_checks
headscale-webui | if not key_check(): return 'settings_page'
headscale-webui | ^^^^^^^^^^^
headscale-webui | File "/app/helper.py", line 58, in key_check
headscale-webui | api_key = headscale.get_api_key()
headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^
headscale-webui | File "/app/headscale.py", line 66, in get_api_key
headscale-webui | decrypted_key = fernet.decrypt(enc_api_key).decode()
headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/fernet.py", line 90, in decrypt
headscale-webui | return self._decrypt_data(data, timestamp, time_info)
headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/fernet.py", line 151, in _decrypt_data
headscale-webui | self._verify_signature(data)
headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/fernet.py", line 135, in _verify_signature
headscale-webui | raise InvalidToken
headscale-webui | cryptography.fernet.InvalidToken
headscale-webui | [2023-10-22 14:25:04 -0400] [8] [ERROR] Error handling request /favicon.ico
headscale-webui | Traceback (most recent call last):
headscale-webui | File "/app/.venv/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 136, in handle
headscale-webui | self.handle_request(listener, req, client, addr)
headscale-webui | File "/app/.venv/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 169, in handle_request
headscale-webui | resp, environ = wsgi.create(req, client, addr,
headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
headscale-webui | File "/app/.venv/lib/python3.11/site-packages/gunicorn/http/wsgi.py", line 183, in create
headscale-webui | path_info = path_info.split(script_name, 1)[1]
headscale-webui | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
headscale-webui | IndexError: list index out of range

@MartinJohannesNilsen
Copy link

WebUI Internal Server Error:

getting the below error :

headscale-webui | [2023-10-22 14:25:04,859] INFO in helper: All startup checks passed. headscale-webui | [2023-10-22 14:25:04,860] ERROR in app: Exception on / [GET] headscale-webui | Traceback (most recent call last): headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/fernet.py", line 133, in _verify_signature headscale-webui | h.verify(data[-32:]) headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/hmac.py", line 70, in verify headscale-webui | ctx.verify(signature) headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/hazmat/backends/openssl/hmac.py", line 84, in verify headscale-webui | raise InvalidSignature("Signature did not match digest.") headscale-webui | cryptography.exceptions.InvalidSignature: Signature did not match digest. headscale-webui | headscale-webui | During handling of the above exception, another exception occurred: headscale-webui | headscale-webui | Traceback (most recent call last): headscale-webui | File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 2190, in wsgi_app headscale-webui | response = self.full_dispatch_request() headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1486, in full_dispatch_request headscale-webui | rv = self.handle_user_exception(e) headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1484, in full_dispatch_request headscale-webui | rv = self.dispatch_request() headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1469, in dispatch_request headscale-webui | return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/server.py", line 114, in decorated headscale-webui | return view_func(*args, **kwargs) headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/server.py", line 141, in overview_page headscale-webui | pass_checks = str(helper.load_checks()) headscale-webui | ^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/helper.py", line 301, in load_checks headscale-webui | if not key_check(): return 'settings_page' headscale-webui | ^^^^^^^^^^^ headscale-webui | File "/app/helper.py", line 58, in key_check headscale-webui | api_key = headscale.get_api_key() headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/headscale.py", line 66, in get_api_key headscale-webui | decrypted_key = fernet.decrypt(enc_api_key).decode() headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/fernet.py", line 90, in decrypt headscale-webui | return self._decrypt_data(data, timestamp, time_info) headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/fernet.py", line 151, in _decrypt_data headscale-webui | self._verify_signature(data) headscale-webui | File "/app/.venv/lib/python3.11/site-packages/cryptography/fernet.py", line 135, in _verify_signature headscale-webui | raise InvalidToken headscale-webui | cryptography.fernet.InvalidToken headscale-webui | [2023-10-22 14:25:04 -0400] [8] [ERROR] Error handling request /favicon.ico headscale-webui | Traceback (most recent call last): headscale-webui | File "/app/.venv/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 136, in handle headscale-webui | self.handle_request(listener, req, client, addr) headscale-webui | File "/app/.venv/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 169, in handle_request headscale-webui | resp, environ = wsgi.create(req, client, addr, headscale-webui | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ headscale-webui | File "/app/.venv/lib/python3.11/site-packages/gunicorn/http/wsgi.py", line 183, in create headscale-webui | path_info = path_info.split(script_name, 1)[1] headscale-webui | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^ headscale-webui | IndexError: list index out of range

I get a similar one myself:

[2024-02-15 16:04:17 +0000] [55786] [ERROR] Error handling request /
Traceback (most recent call last):
  File "/home/azureuser/.cache/pypoetry/virtualenvs/headscale-webui-ScX_r6iC-py3.11/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 136, in handle
    self.handle_request(listener, req, client, addr)
  File "/home/azureuser/.cache/pypoetry/virtualenvs/headscale-webui-ScX_r6iC-py3.11/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 169, in handle_request
    resp, environ = wsgi.create(req, client, addr,
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/azureuser/.cache/pypoetry/virtualenvs/headscale-webui-ScX_r6iC-py3.11/lib/python3.11/site-packages/gunicorn/http/wsgi.py", line 183, in create
    path_info = path_info.split(script_name, 1)[1]
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range
[2024-02-15 16:04:17 +0000] [55786] [ERROR] Error handling request /favicon.ico
Traceback (most recent call last):
  File "/home/azureuser/.cache/pypoetry/virtualenvs/headscale-webui-ScX_r6iC-py3.11/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 136, in handle
    self.handle_request(listener, req, client, addr)
  File "/home/azureuser/.cache/pypoetry/virtualenvs/headscale-webui-ScX_r6iC-py3.11/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 169, in handle_request
    resp, environ = wsgi.create(req, client, addr,
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/azureuser/.cache/pypoetry/virtualenvs/headscale-webui-ScX_r6iC-py3.11/lib/python3.11/site-packages/gunicorn/http/wsgi.py", line 183, in create
    path_info = path_info.split(script_name, 1)[1]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants