Conversation
The `api_process` and `api_process_raw` decorators silently swallowed any `HassioError` that bubbled up from endpoint handlers, returning `"Unknown error, see Supervisor logs"` to the caller while logging nothing. This made the response message actively misleading: e.g. when an endpoint touching D-Bus hit `DBusNotConnectedError` (raised without a message by `@dbus_connected`), Core would surface `SupervisorBadRequestError: Unknown error, see Supervisor logs` and the Supervisor logs would contain no trace of it. Log the caught `HassioError` with traceback before delegating to `api_return_error` so the "see Supervisor logs" hint is actually actionable. The `APIError` branch is left alone — those carry explicit status codes and messages set by Supervisor code and are already visible in the response. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mdegat01
left a comment
There was a problem hiding this comment.
I'm fine with this. It feels like the flaw might be with the point at which the exception is raised though. HassioError means handled and if logging to inform the user is needed we should do that at the point we raise it right?
"HassioError means handled" is maybe a bit overstatement. I means it is an exception created by us, but some of them are quite low level and come without any text (like the IMHO, for the well handled exception cases we should have exception classes deriving from This PR is about |
Non-APIError HassioError exceptions reaching api_process indicate missing error handling in the endpoint handler. In addition to the logging added in the previous commit, also send these to Sentry so they surface as actionable issues rather than silently returning "Unknown error, see Supervisor logs" to the caller.
mdegat01
left a comment
There was a problem hiding this comment.
Ok I get it now. HassioError captured after APIError so its specifically to catch the non-APIError exceptions raised. This makes sense then.
As for sentry noise, I don't really know how much this will be. I think passing them to sentry and letting it aggregate them for us provides us the best way to track them down and improve handling so I'd say lets try it. If its clearly too noisy we'll drop it if necessary but I'd rather just quickly address the main problem points if possible with better logging and an APIError instead.
Proposed change
The
api_processandapi_process_rawdecorators silently swallowed anyHassioErrorthat bubbled up from endpoint handlers. The wrapped handler caught the exception, returned an error response, but never logged anything. When the exception also had no message (e.g.DBusNotConnectedErrorraised without arguments by@dbus_connected),api_return_errorfalls back to"Unknown error, see Supervisor logs"— telling the caller to check logs that contain literally nothing about the failure.Concretely, Core's
analytics.save_preferenceshittingPOST /supervisor/optionswithdiagnostics=trueon a host without OS-Agent on the bus (e.g. the Supervisor devcontainer) produces:…with no corresponding Supervisor log line to go look at.
This PR logs the caught
HassioErrorwith traceback in bothapi_processandapi_process_rawbefore delegating toapi_return_error, so the "see Supervisor logs" hint is actually actionable. TheAPIErrorbranch is intentionally left alone — those carry explicit status codes and messages set by Supervisor code and are already visible in the response, so logging them would just be noise (e.g. validation errors).This does not fix the underlying missing message on
DBusNotConnectedErroritself (that's a follow-up), but it makes any future occurrence of this pattern diagnosable from the logs alone.Type of change
Additional information
Checklist
ruff format supervisor tests)If API endpoints or add-on configuration are added/changed: