actions: Raise an exception if privileged server response is empty

- These situation occur when server encounters an error when trying to formulate
a response. All exceptions during execution of actions are caught and reported
properly. However, server may encounter errors during processing of exception
raised in an action. Or may die abruptly. This special error will make
identifying such situations easier.

Tests:

- Add a 'return' after _read_request() in
privileged_daemon.py:RequestHandler:handle(). This will trigger this error.
Starting FreedomBox service will show these errors as 'ConnectionError: Server
returned empty response'. Similarly running 'freedombox-cmd --no-args plinth
is_package_manager_busy' will show the same error.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa 2025-09-26 13:28:47 -07:00 committed by Veiko Aasa
parent f19ab68553
commit 279738c305
No known key found for this signature in database
GPG Key ID: 478539CAE680674E

View File

@ -88,6 +88,9 @@ def _read_from_server(client_socket: socket.socket) -> bytes:
response += chunk
if not response:
raise ConnectionError('Server returned empty response')
return json.loads(response)