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

java.lang.NullPointerException: Cannot invoke "java.lang.Boolean.booleanValue()" because the return value of "growthbook.sdk.java.ParentCondition.getGate()" is null #117

Closed
aalenkin-uzum opened this issue Feb 4, 2025 · 3 comments

Comments

@aalenkin-uzum
Copy link

aalenkin-uzum commented Feb 4, 2025

Hello!
I'm using Java SDK version 0.9.91.

I created a holdout feature and experiment according to the documentation and tied them to a business feature.
Field "gate" of ParentCondition block marked as optional in documentation.
I receive this json configuration from GrowthBook:

{
  "status": 200,
  "features": {
    "recsys_favorite_page_retrieval_config": {
      "defaultValue": {
        "featureVal": "default"
      },
      "rules": [
        {
          "condition": {
            "account_id": {
              "$exists": true
            }
          },
          "parentConditions": [
            {
              "id": "recsys_holdout_testing_feature",
              "condition": {
                "value": true
              }
            }
          ],
          "coverage": 1,
          "hashAttribute": "account_id",
          "bucketVersion": 1,
          "seed": "d97d9fb1-9ea6-448b-a088-b67f7f1dc75e",
          "hashVersion": 2,
          "variations": [
            {
              "featureVal": "variation a"
            },
            {
              "featureVal": "variation b"
            }
          ],
          "weights": [
            0.5,
            0.5
          ],
          "key": "recsys_temp_exp_holdout_123",
          "meta": [
            {
              "key": "0",
              "name": "Control"
            },
            {
              "key": "1",
              "name": "Variation 1"
            }
          ],
          "phase": "0",
          "name": "recsys_temp_exp_holdout"
        }
      ]
    },
    "recsys_holdout_testing_feature": {
      "defaultValue": true,
      "rules": [
        {
          "coverage": 0.1,
          "hashAttribute": "account_id",
          "bucketVersion": 1,
          "seed": "9a82ed9c-cda6-4b3c-83d9-468075fabb49",
          "hashVersion": 2,
          "variations": [
            false,
            true
          ],
          "weights": [
            0.5,
            0.5
          ],
          "key": "test_recsys_holdout",
          "meta": [
            {
              "key": "0",
              "name": "Control"
            },
            {
              "key": "1",
              "name": "Variation 1"
            }
          ],
          "phase": "0",
          "name": "test_recsys_holdout"
        }
      ]
    }
  },
  "dateUpdated": "2025-02-04T16:21:25.186Z"
}

parentConditions block has no field "gate" here and I don't know how to put it there.

"parentConditions": [
            {
              "id": "recsys_holdout_testing_feature",
              "condition": {
                "value": true
              }
            }
          ]

With this json-configuration im getting exception from SDK:

ERROR 69022 --- [           main] growthbook.sdk.java.FeatureEvaluator     : Cannot invoke "java.lang.Boolean.booleanValue()" because the return value of "growthbook.sdk.java.ParentCondition.getGate()" is null

java.lang.NullPointerException: Cannot invoke "java.lang.Boolean.booleanValue()" because the return value of "growthbook.sdk.java.ParentCondition.getGate()" is null
	at growthbook.sdk.java.FeatureEvaluator.evaluateFeature(FeatureEvaluator.java:191) ~[growthbook-sdk-java-0.9.91.jar:na]
	at growthbook.sdk.java.GrowthBook.evalFeature(GrowthBook.java:80) ~[growthbook-sdk-java-0.9.91.jar:na]

I think this is because the field is marked as optional, but there is an explicit call to parentCondition.getGate() in the code, that causes the NPE:

Image

It looks like this is being reproduced specifically for users who were included in the holdout

Please tell me what is causing the error - a bug in the SDK, incorrect experiment holdout configuration, or something else?

@vazarkevych
Copy link
Collaborator

Hi, @aalenkin-uzum . Thank you we will check that.

@vazarkevych
Copy link
Collaborator

Hi @aalenkin-uzum. We have checked this issue, and yes, it is a bug in the SDK. The problem arises from incorrect handling of the optional gate field in the ParentCondition object. We have fixed this issue in the following PR, and the problem with the gate variable has been addressed in this commit. Thank you for your patience!

@vazarkevych
Copy link
Collaborator

Hi, @aalenkin-uzum.

The fix for this issue is now available in release 0.9.93.
Please check it out and let us know if you encounter any further issues.

📌 Release notes: link_to_release

Thanks again for your patience!

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

No branches or pull requests

2 participants