Skip to content

Commit b7d0d04

Browse files
typotterdevflow.devflow-routing-intake
andauthored
Update evaluation reason for empty waterfall to DEFAULT instead of ERROR/GENERAL per REASON.9 (#11193)
Fix REASON-9: empty allocations waterfall returns DEFAULT not GENERAL fix(ffe): add null-allocations guard; fix empty-allocs test expectation - DDEvaluator: add explicit null check for flag.allocations before the iteration loop. A null list throws NPE which gets swallowed as GENERAL; returning GENERAL explicitly with a clear message is safer and testable. - DDEvaluatorTest.testNoAllocations: the empty-allocation case already falls through the for-loop to the DEFAULT return; the test was asserting ERROR/GENERAL which contradicts the fix. Update to assert DEFAULT with no error code. Update error message for null allocations in feature flag Co-authored-by: devflow.devflow-routing-intake <devflow.devflow-routing-intake@kubernetes.us1.ddbuild.io>
1 parent 1602f06 commit b7d0d04

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

products/feature-flagging/feature-flagging-api/src/main/java/datadog/trace/api/openfeature/DDEvaluator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ public <T> ProviderEvaluation<T> evaluate(
101101
.build();
102102
}
103103

104-
if (isEmpty(flag.allocations)) {
105-
return error(defaultValue, ErrorCode.GENERAL, "Missing allocations for flag " + flag.key);
104+
if (flag.allocations == null) {
105+
return error(defaultValue, ErrorCode.GENERAL, "Missing allocations for flag " + key);
106106
}
107107

108108
final Date now = new Date();

products/feature-flagging/feature-flagging-api/src/test/java/datadog/trace/api/openfeature/DDEvaluatorTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import static java.util.Collections.emptyMap;
1414
import static java.util.Collections.singletonList;
1515
import static org.hamcrest.CoreMatchers.equalTo;
16+
import static org.hamcrest.CoreMatchers.nullValue;
1617
import static org.hamcrest.MatcherAssert.assertThat;
1718
import static org.hamcrest.Matchers.hasEntry;
1819
import static org.hamcrest.Matchers.oneOf;
@@ -174,8 +175,8 @@ public void testNoAllocations() {
174175

175176
details = evaluator.evaluate(Integer.class, "empty-allocation", 23, ctx);
176177
assertThat(details.getValue(), equalTo(23));
177-
assertThat(details.getReason(), equalTo(ERROR.name()));
178-
assertThat(details.getErrorCode(), equalTo(ErrorCode.GENERAL));
178+
assertThat(details.getReason(), equalTo(DEFAULT.name()));
179+
assertThat(details.getErrorCode(), nullValue());
179180
}
180181

181182
private static Arguments[] flatteningTestCases() {

0 commit comments

Comments
 (0)