camunda/feel-scala

The function `date()` doesn't return `null` for invalid dates

Opened this issue · 3 comments

saig0 commented

Describe the bug
I can invoke the function date() with an invalid date, for example, "2023-02-29". I expected null but the function returns the last date of the month.

To Reproduce
Steps to reproduce the behavior:

  1. Evaluate the expression date("2023-02-29")
  2. Verify that the result is a date at "2023-02-28"

Expected behavior
The function date() returns null if the date is invalid.

Environment

saig0 commented

⚠️ The expected behavior is not defined in the DMN 1.5 specification. And, there is no test case in the DMN TCK (ref).

I was requested to provide a specific use case:

We don’t have a detailed use case other than parsing a date from a string coming from a request body (we do it in a few tasks).
But since we are new to feel/camunda we were experimenting with the date object and deciding if we wanted all of our date manipulations to happen within the APIs called via the REST connectors (in scala) or to keep them in the model (the easiest option).

Leap years are one of the first things you test when working with dates, so that's how we came across this issue.

But ultimately, if something has gone wrong where we have passed an invalid date to the model, we don’t want it to pick a magic date, we want it to be parsed as null so we know something is wrong somewhere

instead of possibly silently failing with the wrong date

saig0 commented

📥 I reported the issue to the OMG: https://issues.omg.org/browse/DMN17-67.