Skip to content

Commit 04e3230

Browse files
Update src/test/java/dev/openfeature/sdk/testutils/jackson/CelContextEvaluator.java
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Simon Schrottner <[email protected]>
1 parent c7355a9 commit 04e3230

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/test/java/dev/openfeature/sdk/testutils/jackson/CelContextEvaluator.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,17 @@ public CelContextEvaluator(String expression) {
3636
@Override
3737
@SuppressWarnings("unchecked")
3838
public T evaluate(Flag flag, EvaluationContext evaluationContext) {
39-
try {
40-
Map<String, Object> objectMap = new HashMap<>(Map.of("email", ""));
39+
Map<String, Object> objectMap = new HashMap<>();
40+
// Provide defaults for all declared variables to prevent runtime errors.
41+
objectMap.put("email", "");
42+
objectMap.put("customer", "");
43+
objectMap.put("dummy", "");
44+
4145
if (evaluationContext != null) {
42-
// Evaluate with context
46+
// Evaluate with context, overriding defaults.
4347
objectMap.putAll(evaluationContext.asObjectMap());
4448
}
49+
}
4550

4651
Object result = program.eval(objectMap);
4752

0 commit comments

Comments
 (0)