Controller logs: an unparseable since is a 400, not empty logs (#953)

journalctl exits 1 with nothing on stdout when it cannot parse --since
(a bare "1h" is one such value); the controller returned that empty
stdout as the logs, with a 200.  A failed journalctl is now an error:
400 when it could not parse since, 500 otherwise.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
lrnselfreliance 2026-11-08 08:01:27 -07:00 • committed by Roland
parent d25ebb9e63
commit f3f762ef1b
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
4 changed files with 51 additions and 3 deletions

View file

@ -159,6 +159,8 @@ async def service_logs(
result = get_service_logs(name, lines, since)
if "error" in result:
raise HTTPException(status_code=500, detail=result["error"])
# A since journalctl cannot parse is the caller's mistake.
status_code = 400 if result.get("invalid_since") else 500
raise HTTPException(status_code=status_code, detail=result["error"])
return ServiceLogsResponse(**result)