fix: compress_dynamo_documents breaks permanent environment cache#7014
fix: compress_dynamo_documents breaks permanent environment cache#7014khvn26 merged 3 commits intoFlagsmith:mainfrom
compress_dynamo_documents breaks permanent environment cache#7014Conversation
There was a problem hiding this comment.
Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit in Settings → Usage.
Once credits are available, reopen this pull request to trigger a review.
|
@SahilJat is attempting to deploy a commit to the Flagsmith Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
9c36c69 to
251b885
Compare
|
You have used all of your free Bugbot PR reviews. To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial. |
for more information, see https://pre-commit.ci
|
hi @khvn26 all the precommit has been passed the only test failing require authorization , please let me know if its good to go or do i have to make some changes also I noticed that |
|
Sorry @SahilJat — the solution looks sound to me but I'd like the failing tests fixed. Can you see to that? |
compress_dynamo_documents breaks permanent environment cache
LiveReview Pre-Commit Check: skipped
|
hi @khvn26 i made the changes inside the test files , |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7014 +/- ##
==========================================
- Coverage 98.31% 98.27% -0.05%
==========================================
Files 1335 1336 +1
Lines 49784 50047 +263
==========================================
+ Hits 48947 49182 +235
- Misses 837 865 +28 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|

Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Closes #6944
Please describe.
Since
V1EnvironmentDocumentResponseis a TypedDict, I implemented an explicit dictionary extraction right beforeenvironment_document_cache.set_many(). This guarantees that internal DynamoDB configs (like compress_dynamo_documents) do not leak into the Redis cache consumed by the API.I also added a mocked unit test to verify the payload is stripped and perfectly validates against the V1EnvironmentDocumentResponse schema.
How did you test this code?
Please describe.
1.Mocked the Cache: Used @mock.patch to intercept the payload right before it hits environment_document_cache.set_many().
2.Forced Persistent Mode: Set CACHE_ENVIRONMENT_DOCUMENT_MODE to PERSISTENT to trigger the exact code path causing the leak.
2.Asserted Data Stripping: Verified that internal configuration fields (like compress_dynamo_documents and use_v2_feature_versioning) are successfully stripped from the payload.
4.Schema Validation: Explicitly proved that the intercepted dictionary perfectly aligns with the V1EnvironmentDocumentResponse TypedDict, guaranteeing that the public API view will not break.