Skip to content

Use None check for request.id to preserve falsy IDs#3143

Open
bysiber wants to merge 1 commit intosanic-org:mainfrom
bysiber:fix-request-id-none-check
Open

Use None check for request.id to preserve falsy IDs#3143
bysiber wants to merge 1 commit intosanic-org:mainfrom
bysiber:fix-request-id-none-check

Conversation

@bysiber
Copy link

@bysiber bysiber commented Feb 20, 2026

The request.id property uses if not self._id to decide whether to generate/fetch the ID. This treats any falsy value (including 0, "") as "not yet set," causing the ID to be regenerated on every property access.

A custom generate_id() returning 0 or an integer request ID header value of "0" (which gets cast to int(0)) would trigger re-generation every time request.id is read. Switching to is None preserves any explicitly-set falsy ID while still triggering lazy initialization when genuinely unset.

@bysiber bysiber requested a review from a team as a code owner February 20, 2026 03:48
@codecov
Copy link

codecov bot commented Feb 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.817%. Comparing base (785d77f) to head (b712c5c).

Additional details and impacted files
@@              Coverage Diff              @@
##              main     #3143       +/-   ##
=============================================
+ Coverage   87.793%   87.817%   +0.024%     
=============================================
  Files          105       105               
  Lines         8143      8143               
  Branches      1290      1290               
=============================================
+ Hits          7149      7151        +2     
+ Misses         687       686        -1     
+ Partials       307       306        -1     

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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