Skip to content

fix(EastDevonDC): zero-pad UPRN to 12 digits#2050

Open
InertiaUK wants to merge 1 commit into
robbrad:masterfrom
InertiaUK:fix/eastdevon-uprn-padding
Open

fix(EastDevonDC): zero-pad UPRN to 12 digits#2050
InertiaUK wants to merge 1 commit into
robbrad:masterfrom
InertiaUK:fix/eastdevon-uprn-padding

Conversation

@InertiaUK
Copy link
Copy Markdown
Contributor

@InertiaUK InertiaUK commented May 12, 2026

Summary

  • East Devon's website requires 12-digit zero-padded UPRNs
  • Unpadded UPRNs (e.g. from PostGIS/UPRN database lookups) return empty pages with no error
  • Added .zfill(12) to pad the UPRN before building the URL

Summary by CodeRabbit

  • Bug Fixes
    • Fixed UPRN (property reference) formatting for East Devon District Council lookups to ensure proper data retrieval for bin collection schedules.

Review Change Stack

East Devon's website requires 12-digit zero-padded UPRNs. Unpadded
UPRNs (e.g. from PostGIS lookups) return empty pages.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

📝 Walkthrough

Walkthrough

EastDevonDC module corrects its dependency imports and adds UPRN normalization. The module now imports requests directly instead of unused pandas, and normalizes the provided UPRN to a 12-digit zero-padded string before constructing the East Devon collection calendar URL.

Changes

East Devon UPRN Handling

Layer / File(s) Summary
UPRN normalization and dependency fix
uk_bin_collection/uk_bin_collection/councils/EastDevonDC.py
The module imports requests directly instead of pandas, and normalizes the UPRN input using zfill(12) to ensure it is a 12-digit zero-padded identifier before constructing the API request URL.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • robbrad/UKBinCollectionData#1722: Addresses UPRN formatting/encoding across different council implementations; EastDevonDC now zero-pads UPRN while the related PR fixes UPRN string passing in SouthamptonCityCouncil.

Poem

🐰 A UPRN zero-padded right,
Twelve digits shining bright,
Old pandas left behind,
Requests now entwined,
East Devon's URLs take flight! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately describes the main change: adding zero-padding to UPRNs in the EastDevonDC module.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.67%. Comparing base (8ecf878) to head (f7894ad).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2050   +/-   ##
=======================================
  Coverage   86.67%   86.67%           
=======================================
  Files           9        9           
  Lines        1141     1141           
=======================================
  Hits          989      989           
  Misses        152      152           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
uk_bin_collection/uk_bin_collection/councils/EastDevonDC.py (1)

21-28: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fallback URL path is broken by unconditional UPRN padding.

Line 24 pads before the fallback check on Line 26, so legacy calls that rely on url can fail early (or never reach fallback). Gate padding behind a present uprn, then use legacy url otherwise.

💡 Proposed fix
         try:
             user_uprn = kwargs.get("uprn")
-            check_uprn(user_uprn)
-            # East Devon requires 12-digit zero-padded UPRNs
-            user_uprn = user_uprn.zfill(12)
-            url = f"https://eastdevon.gov.uk/recycling-and-waste/recycling-waste-information/when-is-my-bin-collected/future-collections-calendar/?UPRN={user_uprn}"
-            if not user_uprn:
-                # This is a fallback for if the user stored a URL in old system. Ensures backwards compatibility.
-                url = kwargs.get("url")
+            if user_uprn:
+                user_uprn = str(user_uprn)
+                check_uprn(user_uprn)
+                # East Devon requires 12-digit zero-padded UPRNs
+                user_uprn = user_uprn.zfill(12)
+                url = f"https://eastdevon.gov.uk/recycling-and-waste/recycling-waste-information/when-is-my-bin-collected/future-collections-calendar/?UPRN={user_uprn}"
+            else:
+                # This is a fallback for if the user stored a URL in old system. Ensures backwards compatibility.
+                url = kwargs.get("url")
+                if not url:
+                    raise ValueError("Missing identifier: provide 'uprn' or 'url'")

Based on learnings, parser paths should fail explicitly for invalid identifiers rather than failing indirectly after format assumptions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@uk_bin_collection/uk_bin_collection/councils/EastDevonDC.py` around lines 21
- 28, The code pads and validates user_uprn unconditionally which prevents the
legacy url fallback from working; change the logic in the EastDevonDC request
flow so you first check whether kwargs contains an "uprn" (user_uprn) and only
call check_uprn(user_uprn) and user_uprn = user_uprn.zfill(12) when it is
present, otherwise skip padding/validation and set url = kwargs.get("url") as
the fallback; keep the final url assignment using the zero-padded user_uprn only
in the branch where uprn existed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@uk_bin_collection/uk_bin_collection/councils/EastDevonDC.py`:
- Around line 21-28: The code pads and validates user_uprn unconditionally which
prevents the legacy url fallback from working; change the logic in the
EastDevonDC request flow so you first check whether kwargs contains an "uprn"
(user_uprn) and only call check_uprn(user_uprn) and user_uprn =
user_uprn.zfill(12) when it is present, otherwise skip padding/validation and
set url = kwargs.get("url") as the fallback; keep the final url assignment using
the zero-padded user_uprn only in the branch where uprn existed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1893fcc6-6f62-496e-bc06-0d7e84016cb5

📥 Commits

Reviewing files that changed from the base of the PR and between 8ecf878 and f7894ad.

📒 Files selected for processing (1)
  • uk_bin_collection/uk_bin_collection/councils/EastDevonDC.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant