travisghansen / hass-opnsense

OPNsense integration with Home Assistant
Apache License 2.0
229 stars 29 forks source link

[Bug]: wireguard server switch fails with error 500 #284

Closed davidgdlt closed 1 month ago

davidgdlt commented 1 month ago

What happened?

First of all, thanks for implementing this request so fast! Just tried 0.3.7 and toggling the new wireguard server switch fails with Response 500: Internal Server Error

My user has "GUI VPN: WireGuard system" privileges enabled.

hass-opnsense Version

0.3.7

OPNsense Firmware

24.7.6

Home Assistant Version

2024.10.3

Relevant logs

[Note: ip, port, and uid redacted]
2024-10-21 10:31:30.827 ERROR (MainThread) [custom_components.opnsense.pyopnsense] Error in OPNsenseClient.toggle_vpn_instance. Path: https://xxx.xxx.xxx.xxx:yyy/api/wireguard/server/toggleServer/810c59d0-565a-486a-abcd-abcdefghijkl. Response 500: Internal Server Error
2024-10-21 10:32:25.829 ERROR (MainThread) [custom_components.opnsense.pyopnsense] Error in OPNsenseClient.toggle_vpn_instance. Path: https://xxx.xxx.xxx.xxx:yyy/api/wireguard/server/toggleServer/810c59d0-565a-486a-abcd-abcdefghijkl. Response 500: Internal Server Error
2024-10-21 10:32:55.270 ERROR (MainThread) [custom_components.opnsense.pyopnsense] Error in OPNsenseClient.toggle_vpn_instance. Path: https://xxx.xxx.xxx.xxx:yyy/api/wireguard/server/toggleServer/810c59d0-565a-486a-abcd-abcdefghijkl. Response 500: Internal Server Error
2024-10-21 10:33:35.007 DEBUG (MainThread) [custom_components.opnsense.pyopnsense] [post] url: https://xxx.xxx.xxx.xxx:yyy/api/wireguard/server/toggleServer/810c59d0-565a-486a-abcd-abcdefghijkl
2024-10-21 10:33:35.007 DEBUG (MainThread) [custom_components.opnsense.pyopnsense] [post] payload: None
2024-10-21 10:33:35.036 DEBUG (MainThread) [custom_components.opnsense.pyopnsense] [post] Response 500: Internal Server Error
2024-10-21 10:33:35.036 ERROR (MainThread) [custom_components.opnsense.pyopnsense] Error in OPNsenseClient.toggle_vpn_instance. Path: https://xxx.xxx.xxx.xxx:yyy/api/wireguard/server/toggleServer/810c59d0-565a-486a-abcd-abcdefghijkl. Response 500: Internal Server Error

Additional Details

No response

alexdelprete commented 1 month ago

@davidgdlt David, could you please try with an ADMIN user please? Please remember, as per README, that admin user is a pre-requirement. Some things might not work with granular privileges.

Want to make sure that it's not a permission issue, even though the 500 error points to that kind of problem.

Let us know, thanks.

davidgdlt commented 1 month ago

My user is in fact an admin. I also had enabled additional permissions when I initially set it up to support home assistant and never bothered to removed them. In any case, I tried removing these additional (and unnecessary) privileges and retrying but the results were the same.

However, after rebooting Opnsense it somehow started working. Not sure if this is what solved whatever issue I had or it was only circumstancial, but after coming back from the reboot there were no more 500 errors and the switch does now toggle the server in Opnsense.

Closing the bug, thanks.