feat: Avoid updating populated store with empty configs during init#36
Closed
stephenreid wants to merge 1 commit intostatsig-io:mainfrom
Closed
Conversation
Author
|
@lfoster-statsig For consideration for those of us who have implemented Redis (or other persistence) with an iDataStore interface to share across multi-instance envs |
Contributor
Honestly do think this is a beneficial idea, will get more eyes internally |
Author
|
The test failure appears to be a change in how the sdk key is passed in the test/ci environment between 2.5.0 and 3.2.0 ruby-sdk/test/test_country_lookup.rb Line 43 in e78d90e |
Author
|
The bootstrap and adapter choice already choose this |
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.
Summary
This pull request introduces a safeguard to prevent the local configuration from being wiped when the network returns an empty set of specifications while a data store is in use. This ensures that the SDK continues to use the last known good configuration if the network sync fetches an empty response.
Changes
lib/spec_store.rbis_empty_specs?(specs_json): A private helper method to determine if a given specifications object contains no feature gates, dynamic configs, or layer configs.process_specs(specs_string, from_adapter: false):from_adapteris false), and a data store is configured, the update is skipped (returnsnilearly).test/data_adapter_test.rbtest_datastore_preserves_data_when_network_returns_empty_specs:SpecStore's internal state and the configuredDataStorepreserve the original configuration instead of being overwritten by the empty response.Test Plan
test_datastore_preserves_data_when_network_returns_empty_specsto verify data preservation.Impact
This change improves the resilience of the SDK when using a persistent data store. It prevents a "blank slate" scenario where all feature gates and configurations would temporarily evaluate to their default values if the network sync happens to fetch an empty response.