Handle non-existing variables and context entries gracefully
Closed this issue · 1 comments
saig0 commented
Describe the bug
If I access a non-existing variable then the expression fails. To avoid failure, I must do a null check first.
x
// failed to evaluate expression 'x': no variable found for name 'x'
The behavior is the same for path expressions. If I access a non-existing context entry, the expression fails.
{a: 1}.b
// failed to evaluate expression '{a: 1}.b': context contains no entry with key 'b'
Related to #540.
Related to #582.
To Reproduce
Steps to reproduce the behavior:
- Evaluate the expression
x
- Verify that the expression fails to evaluate
Expected behavior
The expression should return null
if a variable or a context entry doesn't exist.
x = null
{a: 1}.b = null
{a: 1}.b.c = null
null.b = null
If the path expression is applied to a filter and a context doesn't contain the entry, the resulting list should contain null
for this item.
// non-member path filtering
[ { x: 1 }, { y: 2 } ].y = [ null, 2 ]
[ { x: 1 } ].y = [ null ]
The expected behavior is aligned with the DMN spec. It is verified by the TCK test cases:
Environment
- FEEL engine version:
1.16.0
- Affects:
- Camunda Automation Platform 7: [7.x]
- Zeebe broker: [0.x]
korthout commented
ZPA triage:
- good issue for an upcoming mob programming session
- should be resolved before 8.3
- sizing as medium as it takes the team some time to resolve such issues