Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The evaluation of substring() fails if the length is greater than the given string #801

Open
saig0 opened this issue Feb 1, 2024 · 0 comments

Comments

@saig0
Copy link
Member

saig0 commented Feb 1, 2024

Describe the bug
If I invoke the substring() function with a length that is greater than the given string then the evaluation fails and reports a Java StringIndexOutOfBoundsException.

To Reproduce
Steps to reproduce the behavior:

  1. Evaluate the expression substring("abc", 1, 4)
  2. Verify that the evaluation fails with the message
failed to evaluate expression 'substring("abc", 1, 4)' :
 java.lang.StringIndexOutOfBoundsException: begin 0, end 4, length 3

Expected behavior

The function invocation should return the whole string if the length is greater than the string.

substring("abc", 1, 4)    // --> "abc"

However, according to the DMN 1.5 specification, the function invocation should return null.

Screenshot from 2024-02-01 15-26-04

However, returning null is not the most (business) user-friendly behavior. It could lead to complicated expressions, for example:

if string length(message) < 10 then message else substring(message, 1, 10)

Environment

  • FEEL engine version: 1.17.4
  • Affects:
    • Camunda Automation Platform 7: [7.x]
    • Zeebe broker: 8.4.0
@saig0 saig0 added the type: bug label Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant