mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-13 12:16:29 +00:00
Fix Supervisor log fallback for the /follow endpoint (#5354)
When an error occurs when streaming Supervisor logs, the fallback method receives the follow kwarg as well, which is invalid for the Docker log handler: TypeError: APISupervisor.logs() got an unexpected keyword argument 'follow' The exception is still printed to the logs but with all the extra noise caused by this error. Removing the argument makes the stack trace more comprehensible and the fallback actually works as desired.
This commit is contained in:
parent
95c638991d
commit
cc9a931baa
@ -413,6 +413,7 @@ class RestAPI(CoreSysAttributes):
|
||||
# No need to capture HostNotSupportedError to Sentry, the cause
|
||||
# is known and reported to the user using the resolution center.
|
||||
capture_exception(err)
|
||||
kwargs.pop("follow", None) # Follow is not supported for Docker logs
|
||||
return await api_supervisor.logs(*args, **kwargs)
|
||||
|
||||
self.webapp.add_routes(
|
||||
|
@ -183,6 +183,17 @@ async def test_api_supervisor_fallback(
|
||||
b"\x1b[36m22-10-11 14:04:23 DEBUG (MainThread) [supervisor.utils.dbus] D-Bus call - org.freedesktop.DBus.Properties.call_get_all on /io/hass/os/AppArmor\x1b[0m",
|
||||
]
|
||||
|
||||
# check fallback also works for the follow endpoint (no mock reset needed)
|
||||
|
||||
with patch("supervisor.api._LOGGER.exception") as logger:
|
||||
resp = await api_client.get("/supervisor/logs/follow")
|
||||
logger.assert_called_once_with(
|
||||
"Failed to get supervisor logs using advanced_logs API"
|
||||
)
|
||||
|
||||
assert resp.status == 200
|
||||
assert resp.content_type == "text/plain"
|
||||
|
||||
journald_logs.reset_mock()
|
||||
|
||||
# also check generic Python error
|
||||
|
Loading…
x
Reference in New Issue
Block a user