Skip to content

Commit 7be7e3d

Browse files
committed
wip + fix django_id
1 parent 4dcdaed commit 7be7e3d

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/main/java/com/flagsmith/mappers/EngineMappers.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,24 @@ private static List<FeatureContext> mapEnvironmentDocumentFeatureStatesToFeature
276276
return featureContexts;
277277
}
278278

279+
/**
280+
* Gets the feature state key from either django_id or featurestate_uuid.
281+
*
282+
* @param featureState the feature state JSON
283+
* @return the feature state key as string
284+
*/
285+
private static String getFeatureStateKey(JsonNode featureState) {
286+
JsonNode node = featureState.get("django_id");
287+
if (node != null && !node.isNull()) {
288+
return node.asText();
289+
}
290+
node = featureState.get("featurestate_uuid");
291+
if (node != null && !node.isNull()) {
292+
return node.asText();
293+
}
294+
return "";
295+
}
296+
279297
/**
280298
* Maps a single feature state to feature context.
281299
*
@@ -286,7 +304,7 @@ private static FeatureContext mapFeatureStateToFeatureContext(JsonNode featureSt
286304
JsonNode feature = featureState.get("feature");
287305

288306
FeatureContext featureContext = new FeatureContext()
289-
.withKey(featureState.get("id").asText())
307+
.withKey(getFeatureStateKey(featureState))
290308
.withFeatureKey(feature.get("id").asText())
291309
.withName(feature.get("name").asText())
292310
.withEnabled(featureState.get("enabled").asBoolean())

0 commit comments

Comments
 (0)