Skip to content

Conversation

@khvn26
Copy link
Member

@khvn26 khvn26 commented Jan 15, 2026

Contributes to Flagsmith/flagsmith#6394, https://github.com/Flagsmith/edge-api/issues/508

In this PR, we update the DynamoDB schemas with Compressed variants of the environment document.

A generic JsonGzipped type is introduced that, when used via a Pydantic type adapter, validates the inner type, then JSON-encodes and gzip-compresses it. On the consuming side, the type informs the data shape after decompression.

Gzip is used with mtime=0 and JSON encoding with sort_keys=True to support repeatable results. simplejson library is used so validated decimals are encoded natively.

@khvn26 khvn26 requested a review from a team as a code owner January 15, 2026 09:25
@khvn26 khvn26 requested review from emyller and removed request for a team January 15, 2026 09:25
@codecov-commenter
Copy link

codecov-commenter commented Jan 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.73%. Comparing base (775362d) to head (b49b5f2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #157      +/-   ##
==========================================
+ Coverage   95.67%   95.73%   +0.05%     
==========================================
  Files          85       85              
  Lines        2891     2930      +39     
==========================================
+ Hits         2766     2805      +39     
  Misses        125      125              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +276 to +279
project: JsonGzipped[Project]
"""Project-specific data for this environment. **COMPRESSED**."""
feature_states: JsonGzipped[list[FeatureState]]
"""List of feature states representing the environment defaults. **COMPRESSED**."""
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm thinking maybe adding a suffix to compressed fields is a slightly neater approach.

Suggested change
project: JsonGzipped[Project]
"""Project-specific data for this environment. **COMPRESSED**."""
feature_states: JsonGzipped[list[FeatureState]]
"""List of feature states representing the environment defaults. **COMPRESSED**."""
project_compressed: JsonGzipped[Project]
"""Project-specific data for this environment. **COMPRESSED**."""
feature_states_compressed: JsonGzipped[list[FeatureState]]
"""List of feature states representing the environment defaults. **COMPRESSED**."""

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.

5 participants