fix(remote): answer malformed input with one line and keep secrets out of logs

This commit is contained in:
imSp4rky
2026-11-24 16:56:17 -07:00
parent 3e8c63b067
commit 7735c43061
13 changed files with 351 additions and 44 deletions
+5 -2
View File
@@ -157,11 +157,14 @@ def api_handler(handler: Handler) -> Handler:
async def json_body(request: web.Request) -> Any:
"""The request's JSON body; raises INVALID_INPUT when it does not parse."""
"""The request's JSON object; raises INVALID_INPUT when it does not parse or is not an object."""
try:
return await request.json()
data = await request.json()
except Exception as e:
raise APIError(APIErrorCode.INVALID_INPUT, "Invalid JSON request body", details={"error": str(e)}) from e
if not isinstance(data, dict):
raise APIError(APIErrorCode.INVALID_INPUT, "The request body must be a JSON object")
return data
HEARTBEAT_INTERVAL = 30.0