You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
webhook_handler: pyscript_running includes a non-serializable request and sensitive arguments #898
With Pyscript 2.1.1, a @webhook_handler produces this Home Assistant error:
Event is not JSON serializable: <Event pyscript_running ...>:
Type is not JSON serializable: HomeAssistantRequest
The event's func_args contains the request object, webhook_id and the complete
JSON payload. If the payload contains an authentication token, that token
and the webhook identifier appear in the serialization error log.
The handler can still execute and return its normal response.
In decorator.py, the event is emitted with data.func_args before invoking
the user's function. Therefore, sanitizing logs inside that function does
not prevent this exposure.
Expected behavior:
Emit only serializable, non-sensitive metadata in pyscript_running.
Exclude request, webhook_id and payload from the public event.
Preserve the original arguments internally for the handler, including
request.remote and HTTP response handling.
Converting request to a string would not resolve the exposure of the
payload and webhook identifier. Related debug and timeout logs should
also be reviewed.
Thanks for the detailed report, @carferrer. This is fixed on master and will be in the next release:
e104bda removes the request from the pyscript_running event, which fixes the Event is not JSON serializable error (and the log message that included the payload and webhook id).
keep only logbook func_args in pyscript_running event #900 (thanks @dmamelin) goes further: the event now only includes the arguments the logbook uses (trigger_type, event_type, var_name, value and trigger_time). So the webhook id and payload are no longer stored by the recorder or sent to event subscribers. Your function still receives all of its arguments, including request.
6212284 makes the @webhook_handler timeout and unparsable-body warnings name the function instead of the webhook id.
One caveat: if you turn on debug logging for pyscript, the debug messages still include full function arguments, including webhook payloads. Debug logging is opt-in and meant for troubleshooting, so we've left that as is.
Activity
don't log webhook ids in webhook_handler warnings
craigbarratt commentedon Nov 18, 2026
Thanks for the detailed report, @carferrer. This is fixed on master and will be in the next release:
requestfrom thepyscript_runningevent, which fixes theEvent is not JSON serializableerror (and the log message that included the payload and webhook id).trigger_type,event_type,var_name,valueandtrigger_time). So the webhook id and payload are no longer stored by the recorder or sent to event subscribers. Your function still receives all of its arguments, includingrequest.@webhook_handlertimeout and unparsable-body warnings name the function instead of the webhook id.One caveat: if you turn on debug logging for pyscript, the debug messages still include full function arguments, including webhook payloads. Debug logging is opt-in and meant for troubleshooting, so we've left that as is.