cel-go icon indicating copy to clipboard operation
cel-go copied to clipboard

Inconsistent behavior of getMilliseconds with cel-spec

Open TristonianJones opened this issue 4 years ago • 3 comments

Describe the bug The getMilliseconds behavior matches user expectations but does not match cel-spec. Eventually this function will be deprecated and the spec revised in favor of a function that matches user expectations.

To Reproduce Check which components this affects:

  • [ ] parser
  • [ ] checker
  • [X] interpreter

Sample expression and input that reproduces the issue:

// Returns 23ms rather than converting the value to 1023.
duration("1s23ms").getMilliseconds()

Test setup: See https://github.com/google/cel-spec/pull/206 for more context on how to test this functionality.

Expected behavior The function returns the milliseconds component of the duration.

TristonianJones avatar Sep 21 '21 21:09 TristonianJones

I looked into this issue and figured that duration.go#overloads.TimeGetMilliseconds and duration_test.go#TestDurationGetMilliseconds shall require the changes. If this issue is not assigned yet, can I take a stab at this? I believe this would be an excellent opportunity for me to start contributing here.

kunaltawatia avatar Sep 25 '21 09:09 kunaltawatia

@kunaltawatia The existing behavior should be moved to a new function, but we have yet to finalize the name of the function. I'll follow up here once the new function name is identified and if you're still interested, you are welcome to work on it.

TristonianJones avatar Sep 29 '21 04:09 TristonianJones

Sure, that'd not be a problem. Curious, Is the change of name required to avoid regression, or are there any other reasons?

kunaltawatia avatar Sep 29 '21 06:09 kunaltawatia