Repository navigation
Post-#2154 triage fixes: Aberdeenshire regression (#2158), East Devon, Horsham hardening - #2163
Conversation
parse_data() ignores the page it's given entirely and makes its own request to a specific, working endpoint - but the generic framework fetch to the bare root URL (online.aberdeenshire.gov.uk/) ran first regardless, and the #2073 retry fix correctly turned that URL's persistent 500 into a hard failure, breaking every user's sensors even though the real data endpoint was healthy the whole time. Override get_data() to skip the unused fetch entirely, so this doesn't depend on skip_get_url being present in already-saved HA config data.
eastdevon.gov.uk returns 403 for the default python-requests User-Agent on both the addressfinder API and the calendar page. Send the existing polite scraper identification string (uk-bin-collection/<version>) instead - verified this alone is enough to get past the block, no need to masquerade as a browser.
Matches the retry/backoff pattern already used elsewhere in the codebase. Doesn't fix the council's current persistent connection reset (verified live: still fails after 5 retries, so this is a sustained block/outage, not a transient blip) - this is defensive hardening for future transient failures, not a fix for the live issue.
…into fix/post-merge-triage-fixes
…nto fix/post-merge-triage-fixes
…nto fix/post-merge-triage-fixes
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThree council scrapers receive request-handling updates: Aberdeenshire bypasses the root fetch, East Devon sends scraper headers, and Horsham uses a retry-enabled session. Issue-resolution documentation records related triage and fixes. ChangesCouncil scraper reliability fixes
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2163 +/- ##
=======================================
Coverage 86.89% 86.89%
=======================================
Files 9 9
Lines 1160 1160
=======================================
Hits 1008 1008
Misses 152 152 ☔ View full report in Codecov by Harness. |
Summary
Consolidates the fixes from a fresh full-suite triage run into a single PR (folds in #2159, #2160, #2161, #2162 - now closed as superseded).
parse_data()ignores the page it's given and makes its own request to a working endpoint, but the generic framework fetch to an unused root URL ran first regardless - that URL returns a persistent 500 on the council's own end, and the retry logic correctly (if unfortunately) turned that into a hard failure, breaking every user's sensors. Fixed by overridingget_data()to skip the pointless fetch - works immediately on upgrade, no config changes needed. Verified live: root URL 500s, real data endpoint 200s with valid data, at the same moment.python-requests/x.xUA gets blocked, this project's own polite scraper UA string (get_scraper_user_agent()) works fine. Verified live end-to-end.build_retry_session()for consistency with the rest of the codebase. Does not fix the council's current failure (verified live it still fails after 5 retries - a sustained block, not a transient blip) - this is defensive hardening only.Broader finding (not fixed here, flagging for awareness)
Found 59 councils with the same shape as Aberdeenshire's bug (
parse_data()ignores the fetched page and makes its own request, butskip_get_urlisn't set). Cross-referenced against real failures - only Aberdeenshire is currently affected, the rest haveurlfields pointing somewhere healthy. Worth a slower systematic audit sometime, not urgent.Test plan
poetry run pytest uk_bin_collection/tests custom_components/uk_bin_collection/tests --ignore=uk_bin_collection/tests/step_defs/- 221 passedblack --checkcleanCloses
Fixes #2158
Summary by CodeRabbit
Bug Fixes
Documentation