Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CusrorPaginator null encoding bug #1161

Merged
merged 1 commit into from
Feb 20, 2025

Conversation

joseph-sentry
Copy link
Contributor

the CursorPaginator encodes None values as the string "None", and on decoding it interprets that as just another string which is causing bugs when running the SQL, because we'll be comparing random types against a string instead of against null

this fixes that by assigning a specific value (\x1f) that is unlikely to be in any user provided string that we would want to filter by

@joseph-sentry joseph-sentry requested a review from a team as a code owner February 18, 2025 16:12
Copy link

codecov bot commented Feb 18, 2025

Codecov Report

Attention: Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.

Project coverage is 96.06%. Comparing base (b8a000a) to head (ab1977e).
Report is 7 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
graphql_api/helpers/connection.py 81.81% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1161      +/-   ##
==========================================
- Coverage   96.07%   96.06%   -0.01%     
==========================================
  Files         838      836       -2     
  Lines       19779    20012     +233     
==========================================
+ Hits        19002    19225     +223     
- Misses        777      787      +10     
Flag Coverage Δ
unit 95.92% <81.81%> (-0.05%) ⬇️
unit-latest-uploader 95.92% <81.81%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@codecov-notifications
Copy link

codecov-notifications bot commented Feb 18, 2025

Codecov Report

Attention: Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
graphql_api/helpers/connection.py 81.81% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codecov-qa
Copy link

codecov-qa bot commented Feb 18, 2025

Codecov Report

Attention: Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.

Project coverage is 95.92%. Comparing base (b8a000a) to head (ab1977e).
Report is 7 commits behind head on main.

✅ All tests successful. No failed tests found.

Copy link
Contributor

✅ All tests successful. No failed tests were found.

📣 Thoughts on this report? Let Codecov know! | Powered by Codecov

try:
orderings = b64decode(cursor.encode("ascii")).decode("utf8")
orderings = orderings.split(self.delimiter)
return [None if ordering == "\x1f" else ordering for ordering in orderings]
Copy link
Contributor

Choose a reason for hiding this comment

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

Damn, weird bug/good find

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, make a var for \x1f since we use in multiple places and to explain what the val is/why it's needed

@joseph-sentry joseph-sentry force-pushed the joseph/fix-cursor-paginator branch from 7545d88 to e7d56ac Compare February 18, 2025 18:29
the CursorPaginator encodes `None` values as the string "None", and on
decoding it interprets that as just another string which is causing
bugs when running the SQL, because we'll be comparing random types
against a string instead of against null

this fixes that by assigning a specific value (\x1f) that is unlikely
to be in any user provided string that we would want to filter by
@joseph-sentry joseph-sentry force-pushed the joseph/fix-cursor-paginator branch from e7d56ac to ab1977e Compare February 19, 2025 17:01
@joseph-sentry joseph-sentry added this pull request to the merge queue Feb 19, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 19, 2025
@joseph-sentry joseph-sentry added this pull request to the merge queue Feb 20, 2025
Merged via the queue into main with commit ade58e2 Feb 20, 2025
19 of 23 checks passed
@joseph-sentry joseph-sentry deleted the joseph/fix-cursor-paginator branch February 20, 2025 21:10
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.

2 participants