camunda / feel-scala

FEEL parser and interpreter written in Scala
https://camunda.github.io/feel-scala/
Apache License 2.0
119 stars 46 forks source link

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

Open saig0 opened 2 weeks ago

saig0 commented 2 weeks ago

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 2 weeks ago

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

niekVandebron commented 2 weeks ago

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 5 days ago

:inbox_tray: I reported the issue to the OMG: https://issues.omg.org/issues/lists/unclassified#issue-54671.