Rotation loop permanently dies on a malformed rotation_interval_seconds value #11
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
paul_loth/krautspaceTV#11
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
/admin/settingsacceptsrotation_interval_secondsas a raw string with no server-side validation (type="number"on the input is just an HTML hint, not enforced). Whatever is submitted gets stored as-is viadb.set_setting().backend/rotation.py'srotation_loop()and_render_forced()both doint(await db.get_setting("rotation_interval_seconds", "60"))with no try/except. If the stored value isn't a valid int (empty string, non-numeric, etc.), this raisesValueErrorinside the one-and-only rotation task. Nothing catches it, andbackend/app.py'slifespan()only callsasyncio.create_task(rotation_loop())once — there's no supervisor/restart logic. The task just dies silently (asyncio logs "exception was never retrieved" but the process keeps running otherwise), and the display freezes on whatever was showing until the service is manually restarted.Since the admin UI is intentionally open to anyone on the network (by design, see #3), this is an easy way — accidental or not — to take the whole signage down with a single bad form submission.
Suggested fix
rotation_interval_secondsserver-side in the/admin/settingshandler (reject/clamp non-numeric or out-of-range values with a friendly error instead of storing them).int(...)calls inrotation.pywith a fallback default in case a bad value ever does slip through.Fixed in
73f0db2: added _get_interval() in rotation.py which falls back to the 60s default on any non-numeric/non-positive stored value instead of raising; also wrapped rotation_loop()'s body in a top-level try/except so any future unexpected error retries after 5s instead of permanently killing the task. Added server-side validation on POST /admin/settings — non-numeric or non-positive submissions are now silently rejected (old value kept) rather than stored. Verified live: submitting rotation_interval_seconds=garbage via the LAN port left the old value (20) in place and rotation kept ticking normally.