Same is_available/render double-fetch bug as #17 exists in 4 more slide types #19
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#19
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
#17 fixed this for
rss.py, but the same pattern exists unfixed in four other slide types — each one'sis_available()does a full network request to check reachability, andrender()(called right after, ifis_availablereturned True — seebackend/rotation.py:139-159) does another full request for the same data:backend/slides/mastodon.py:is_available()(line 30-33) callsurl_ok(_timeline_url(...));render()(line 36+) callsfetch_json(_timeline_url(...))— same URL, fetched twice.backend/slides/train.py:is_available()(line 7-10) callsurl_ok(config["api_url"]);render()(line 13+) callsfetch_json(config["api_url"])— same URL, twice.backend/slides/api_status.py:is_available()(line 37-40) callsfetch_json(...)(a full fetch, not even a lightweight check);render()(line 43+) callsfetch_json(...)again with the same URL.backend/slides/matrix.py:is_available()(line 20-23) callsurl_ok(_messages_url(...));render()(line 26+) callsfetch_json(_messages_url(...))— same URL, twice.(
webcam.pyis fine — itsrender()just embeds<img src>directly with no server-side fetch, so there's no duplication there.)Every rotation step that reaches one of these 4 slide types makes 2 outbound requests to the same third-party API for no benefit — same root cause as #17.
Suggested fix
Apply the same fix used for
rss.pyin #17: simplify eachis_available()to a cheap, network-free check (e.g. just confirm the required config fields are present/non-empty), and letrender()'s existing "Unable to load ..." fallback text be the sole failure-surfacing path. Note the same tradeoff called out when #17 was fixed: a misconfigured/dead endpoint will occupy a full rotation interval showing an error message instead of being silently skipped — acceptable for the same reasons it was accepted there.api_status.pyis the worst offender since even its "availability check" does a full JSON fetch+parse rather than the lighterurl_ok()the others use.Where
backend/slides/mastodon.py:30-33,backend/slides/train.py:7-10,backend/slides/api_status.py:37-40,backend/slides/matrix.py:20-23Fixed and deployed.
is_available()in mastodon.py, train.py, api_status.py, and matrix.py no longer makes a network call — each keeps its required-field guard but returns True after that, letting render()'s existing error fallback be the sole failure path. Verified all 4 backend services restarted cleanly and the admin/rotation endpoints still respond correctly.