Use None check for request.id to preserve falsy IDs#3143
Open
bysiber wants to merge 1 commit intosanic-org:mainfrom
Open
Use None check for request.id to preserve falsy IDs#3143bysiber wants to merge 1 commit intosanic-org:mainfrom
bysiber wants to merge 1 commit intosanic-org:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
request.idproperty usesif not self._idto decide whether to generate/fetch the ID. This treats any falsy value (including0,"") as "not yet set," causing the ID to be regenerated on every property access.A custom
generate_id()returning0or an integer request ID header value of"0"(which gets cast toint(0)) would trigger re-generation every timerequest.idis read. Switching tois Nonepreserves any explicitly-set falsy ID while still triggering lazy initialization when genuinely unset.