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
Systemd logs always empty on systems with a battery (json/v2 cannot unmarshal Battery) #2746
Version: hub and agent 0.21.1 (also present on main as of 27af11c)
Problem
On systems that report a battery (laptops), the systemd service sheet always shows "No logs found." Logs work on systems without a battery. The agent advertises jl: true and running journalctl as the agent works; the hub never sends the request to the agent (the request to /api/beszel/systemd/logs returns 200 with {"logs":""} in ~2 ms, vs. ~24 ms on a system without battery).
Cause
getSystemdLogs in internal/hub/api.go reads the system info with
PocketBase's Record.UnmarshalJSONField uses encoding/json/v2. system.Battery is [2]uint8 and only implements MarshalJSON (numeric array). json/v2 expects a base64 string for [N]byte by default, so unmarshalling "bat":[59,5] fails:
json: unable to unmarshal JSON array into Go system.Battery within "/bat"
The error is swallowed and treated as "no journal access".
Reproduce
Unmarshal {"bat":[59,5],"jl":true} into system.Info with encoding/json/v2 → error, SystemdLogs stays false. Without bat it works.
Suggested fix
Add an UnmarshalJSON to Battery that accepts a numeric array (mirroring MarshalJSON), and/or log the unmarshal error in getSystemdLogs instead of silently returning empty logs. The existing test TestStatsBatteryNumericArrayUnmarshal only covers json v1.
Thank you both, @aditya-rai-5 for the quick fix and @henrygd for the quick review and merge! Logs from my laptops were the one thing missing, and it's great to see this solved so fast. I really love Beszel: it's lightweight, a pleasure to use, and has become a tool I rely on every day. Thanks for all the work you put into it!
Activity
aditya-rai-5 commentedon Nov 1, 2026
i will working on this and raise a PR shortly
fix(hub): support Battery numeric array unmarshaling with json/v2 (#2746
andreasmuellerka commentedon Nov 5, 2026
Thank you both, @aditya-rai-5 for the quick fix and @henrygd for the quick review and merge! Logs from my laptops were the one thing missing, and it's great to see this solved so fast. I really love Beszel: it's lightweight, a pleasure to use, and has become a tool I rely on every day. Thanks for all the work you put into it!
Update henrygd/beszel-agent Docker tag to v0.21.2 (#47)
Update ghcr.io/henrygd/beszel/beszel Docker tag to v0.21.2 (#46)