-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
LD API version 20240415 made a breaking change in the list flags API that will cause the environments field to be only returned if an explicit environment is requested, but the Java model still requires it as a mandatory field, so it will throw an exception unless we filter any environment.
Sample code
ApiClient oldApiClient = Configuration.getDefaultApiClient();
oldApiClient.setApiKey("api-XXXXXXXXXXXXXX");
oldApiClient.addDefaultHeader("LD-API-Version", "20220603");
FeatureFlagsApi oldFlagsApi = new FeatureFlagsApi(oldApiClient);
// Works fine, sample-environment is part of the flags
oldFlagsApi.getFeatureFlags("sample-project", "sample-environment", null, null, null, false, false, null, null, false, null);
// Works fine, all environments are part of the flags
oldFlagsApi.getFeatureFlags("sample-project", null, null, null, null, false, false, null, null, false, null);
ApiClient newApiClient = Configuration.getDefaultApiClient();
newApiClient.setApiKey("api-XXXXXXXXXXXXXX");
newApiClient.addDefaultHeader("LD-API-Version", "20240415");
FeatureFlagsApi newFlagsApi = new FeatureFlagsApi(newApiClient);
// Works fine, sample-environment is part of the flags
newFlagsApi.getFeatureFlags("sample-project", "sample-environment", null, null, null, false, false, null, null, false, null);
// Throws exception
newFlagsApi.getFeatureFlags("sample-project", null, null, null, null, false, false, null, null, false, null);Error
Exception in thread "main" java.lang.IllegalArgumentException: The required field `environments` is not found in the JSON string: {.........}
at com.launchdarkly.api.model.FeatureFlag.validateJsonObject(FeatureFlag.java:893)
at com.launchdarkly.api.model.FeatureFlags.validateJsonObject(FeatureFlags.java:308)
at com.launchdarkly.api.model.FeatureFlags$CustomTypeAdapterFactory$1.read(FeatureFlags.java:351)
at com.launchdarkly.api.model.FeatureFlags$CustomTypeAdapterFactory$1.read(FeatureFlags.java:324)
at com.google.gson.TypeAdapter$1.read(TypeAdapter.java:199)
at com.google.gson.Gson.fromJson(Gson.java:932)
at com.google.gson.Gson.fromJson(Gson.java:897)
at com.google.gson.Gson.fromJson(Gson.java:846)
at com.launchdarkly.api.JSON.deserialize(JSON.java:446)
at com.launchdarkly.api.ApiClient.deserialize(ApiClient.java:847)
at com.launchdarkly.api.ApiClient.handleResponse(ApiClient.java:1055)
at com.launchdarkly.api.ApiClient.execute(ApiClient.java:979)
at com.launchdarkly.api.api.FeatureFlagsApi.getFeatureFlagsWithHttpInfo(FeatureFlagsApi.java:1391)
at com.launchdarkly.api.api.FeatureFlagsApi.getFeatureFlags(FeatureFlagsApi.java:1358)
Metadata
Metadata
Assignees
Labels
No labels