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 evaluating force property in rule when rule is JsonObject and defined as null #112

Merged
merged 2 commits into from
Jan 31, 2025

Conversation

vazarkevych
Copy link
Collaborator

Fix evaluating force property in rule when rule is JsonObject and defined as null

@@ -431,4 +433,8 @@ private void addFeatureToEvalStack(String featureKey, EvaluationContext context)
context.getStack().setId(featureKey);
context.getStack().getEvaluatedFeatures().add(featureKey);
}

private static boolean hasForceProperty(JsonElement featureJson, int i) {
return featureJson.getAsJsonObject().get("rules").getAsJsonArray().get(i).getAsJsonObject().has("force");
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we fix the marshalling to make the FeatureRule read from this place, so that attribute "force" is properly mapped in FeatureRule ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, sure. We are now working on that.

@vazarkevych vazarkevych merged commit 9e9ce7c into release/0.9.92 Jan 31, 2025
1 check passed
@vazarkevych vazarkevych deleted the fix-force-property branch January 31, 2025 13:19
vazarkevych added a commit that referenced this pull request Feb 3, 2025
* SDK version was updated

* LocalGbFeatureRepository (#101)

* LocalGbFeatureRepository was added

* Code cleanup

* Error fix

---------

Co-authored-by: Bohdan Akimenko <[email protected]>

* IGBFeaturesRepository implementation based on java.net.HttpURLConnection (#100)

Co-authored-by: Bohdan Akimenko <[email protected]>

* Constants interface was removed

* Docs were updated (#103)

Co-authored-by: Bohdan Akimenko <[email protected]>

* Changes from comment

* Changes to enable Multi Context Support (#106)

* changes for multi context sdk

* remove debug statements

* handle empty attributes for force

* remove debug statements

* fix javadoc comments

* support attributes as a string

* add GrowthBookMultiUser details

* remove debug statements

* add feature refresh callbacks

* remove debug statements

* fix incorrect example value in README.md

* remove obsolete files

* deprecate encKey

* deprecate encKey

* Use global context at instance level

* LRU cache for tracking experiments

* Changes from comment

* reset stackContext for eval in old instance

* rename GNMultiUser to GBClient

* add unit tests

* fix parent cond evaluation

* changes for multi context sdk

* remove debug statements

* handle empty attributes for force

* remove debug statements

* fix javadoc comments

* support attributes as a string

* add GrowthBookMultiUser details

* remove debug statements

* add feature refresh callbacks

* remove debug statements

* fix incorrect example value in README.md

* remove obsolete files

* deprecate encKey

* deprecate encKey

* Use global context at instance level

* LRU cache for tracking experiments

* reset stackContext for eval in old instance

* rename GNMultiUser to GBClient

* add unit tests

* fix parent cond evaluation

---------

Co-authored-by: Bohdan Akimenko <[email protected]>

* fix trackdata in evaluation process, add remote eval feature, fix tests add test for LocalGbFeatureRepository and NativeJavaGbFeatureRepository; add ability to pass requestBody for madhu variant of GBClient; fix test, add remote eval feature to new flow of initialize GB

* fix logic of subscriptions; add subscriptions to GBClient; (#113)

add experiment parameter to callback

Co-authored-by: Bohdan Akimenko <[email protected]>

* update guava dependency (#111)

Co-authored-by: Bohdan Akimenko <[email protected]>

* fix logic of subscriptions; add subscriptions to GBClient; add experiment parameter to callback

* Manual forced feature  (#108)

* add ability to evaluate manual force feature

* fix logic of subscriptions; add subscriptions to GBClient;
add experiment parameter to callback

* initialize dependencies through constructors in main classes, remove getter and setter for forcedFeatureValues in GBClient, fix test

* add setter and getter for attributeOverrides, make assigned experiments final, fix initialising savedGroups and attributeOverrides through setter and constructors

---------

Co-authored-by: Bohdan Akimenko <[email protected]>

* remove FeatureEvalContext.java, remove from AssignedExperiment objects of experiment and result, replace them with key, inExperiment variable and variationId, fix fireSubscriptions function

* replace map as request body with specific Payload class and configure this payload object with data from Options, fix logic of getting forceVariation and forceFeatureValues from global context and user context, fix test

* make fetchFeatures and fetchForRemoteEval public to  be able to refresh features, remove Payload field from GrowthBookClient, rename payload to RequestBodyForRemoteEval, add setters for global: attributes, forceFeatures, forceVariations, add refresh functions, fix test and reorganize code

* add tests for remote eval

* Improvements for Remote Evaluation  (#109)

* fix trackdata in evaluation process, add remote eval feature, fix tests add test for LocalGbFeatureRepository and NativeJavaGbFeatureRepository; add ability to pass requestBody for madhu variant of GBClient; fix test, add remote eval feature to new flow of initialize GB

* fix logic of subscriptions; add subscriptions to GBClient; add experiment parameter to callback

* remove FeatureEvalContext.java, remove from AssignedExperiment objects of experiment and result, replace them with key, inExperiment variable and variationId, fix fireSubscriptions function

* replace map as request body with specific Payload class and configure this payload object with data from Options, fix logic of getting forceVariation and forceFeatureValues from global context and user context, fix test

* make fetchFeatures and fetchForRemoteEval public to  be able to refresh features, remove Payload field from GrowthBookClient, rename payload to RequestBodyForRemoteEval, add setters for global: attributes, forceFeatures, forceVariations, add refresh functions, fix test and reorganize code

---------

Co-authored-by: Bohdan Akimenko <[email protected]>
Co-authored-by: Volodymyr Nazarkevych <[email protected]>
Co-authored-by: Volodymyr Nazarkevych <[email protected]>

* pass  requestBodyForRemoteEval to refreshForRemoteEval function, update README.md

* fix Readme explanation for functions

* fix import

* Add caching logic to Growthbook repositories (#114)

* Add caching logic to GBFeaturesRepository and NativeJavaGbFeatureRepository

* Add test for CachingManager and add caching logic for GBFeaturesRepository

* improve caching in NativeJavaGbFeatureRepository to reduce double fetching from cache

* fix code

* fix conflicts after merge release 0.9.92 to feature/caching enable branch

---------

Co-authored-by: Volodymyr Nazarkevych <[email protected]>

* fix tests

* comment shouldHandleLargeContent test

* comment shouldThrowExceptionWhenReadingFails test

* Fix evaluating force property in rule when rule is JsonObject and defined as null (#112)

* fix evaluating force property in rule when rule is JsonObject and defined as null

* replace hasForceProperty logic with wrapper to distinguish if force field is present in response or not

---------

Co-authored-by: Bohdan Akimenko <[email protected]>

* Throw exception on HTTP errors (#115)

* Throw exception on HTTP errors

Adds a new FeatureFetchErrorCode called HTTP_RESPONSE_ERROR that is used on non-200 HTTP status codes and also logs the server response.

One of the common instances this happens is when you use a wrong SDK key.

They were previously mangled into FeatureFetchErrorCode.CONFIGURATION_ERROR with a very non-descriptive message of "No features found".

* Fix conflicts after adding caching logic, update mergeMaps function, add a new constructor to GBFeaturesRepository, and refine onSuccess logic based on client feedback.

---------

Co-authored-by: Volodymyr Nazarkevych <[email protected]>

---------

Co-authored-by: Bohdan Akimenko <[email protected]>
Co-authored-by: Madhu Chavva <[email protected]>
Co-authored-by: Volodymyr Nazarkevych <[email protected]>
Co-authored-by: Volodymyr Nazarkevych <[email protected]>
Co-authored-by: Martin Thurau <[email protected]>
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.

3 participants