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: No pagination when querying environments_v2 #3661

Merged
merged 2 commits into from
Mar 25, 2024

Conversation

khvn26
Copy link
Member

@khvn26 khvn26 commented Mar 25, 2024

Thanks for submitting a PR! Please check the boxes below:

  • I have run pre-commit to check linting
  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

This adds pagination to environments_v2 querying code to allow returning more than 1MB of identity overrides.

How did you test this code?

Added a unit test for the case when DDB query gets more than one page of results.

@khvn26 khvn26 requested review from a team and matthewelwell and removed request for a team March 25, 2024 13:13
Copy link

vercel bot commented Mar 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 25, 2024 1:22pm
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 25, 2024 1:22pm
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 25, 2024 1:22pm

Copy link
Contributor

@zachaysan zachaysan left a comment

Choose a reason for hiding this comment

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

I think I understand the code and it looks good. One question below.

Comment on lines +87 to +98
assert results == [override_document, override_document]
wrapper.table.query.assert_has_calls(
[
mocker.call(
KeyConditionExpression=mocker.ANY,
),
mocker.call(
KeyConditionExpression=mocker.ANY,
ExclusiveStartKey=last_evaluated_key,
),
]
)
Copy link
Contributor

Choose a reason for hiding this comment

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

So just to make sure I'm understanding this correctly: All the pages are returned in a single call. The response to the client could potentially span multiple documents that could be quite long?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep. We have a customer with thousands of identity overrides for a single feature which prompted us to come up with this fix

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.87%. Comparing base (361657b) to head (9ffb9d5).
Report is 11 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3661   +/-   ##
=======================================
  Coverage   95.87%   95.87%           
=======================================
  Files        1099     1099           
  Lines       34457    34467   +10     
=======================================
+ Hits        33034    33045   +11     
+ Misses       1423     1422    -1     

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

@khvn26 khvn26 added this pull request to the merge queue Mar 25, 2024
Merged via the queue into main with commit 7e19f4f Mar 25, 2024
23 checks passed
@khvn26 khvn26 deleted the fix/no-environments-v2-pagination branch March 25, 2024 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants