-
Notifications
You must be signed in to change notification settings - Fork 251
Open
Description
Describe the bug
cel-go
inherits RFC 3339 parsing bugs from Golang's time.Parse()
To Reproduce
Check which components this affects:
- parser
- checker
- interpreter
Sample expression and input that reproduces the issue:
(
timestamp("2025-01-17T01:00:00.001Z") ==
timestamp("2025-01-17T01:00:00,001Z") // comma-delimited fractional seconds
) &&
(
timestamp("2025-01-17T01:00:00Z") ==
timestamp("2025-01-17T1:00:00Z") // single-digit hour
) &&
(
timestamp("2025-01-17T01:01:01.001+00:01") ==
timestamp("2025-01-18T01:01:01.001+24:01") // offset > 24:00
) &&
(
timestamp("2025-01-17T01:01:01.001+01:00") ==
timestamp("2025-01-17T01:01:01.001+00:60") // offset minute > 59
)
Test setup:
package main
import (
"fmt"
"github.com/google/cel-go/cel"
)
func main() {
env, _ := cel.NewEnv()
ast, _ := env.Compile(`
(
timestamp("2025-01-17T01:00:00.001Z") ==
timestamp("2025-01-17T01:00:00,001Z") // comma-delimited fractional seconds
) &&
(
timestamp("2025-01-17T01:00:00Z") ==
timestamp("2025-01-17T1:00:00Z") // single-digit hour
) &&
(
timestamp("2025-01-17T01:01:01.001+00:01") ==
timestamp("2025-01-18T01:01:01.001+24:01") // offset > 24:00
) &&
(
timestamp("2025-01-17T01:01:01.001+01:00") ==
timestamp("2025-01-17T01:01:01.001+00:60") // offset minute > 59
)
`)
prg, _ := env.Program(ast)
out, _, _ := prg.Eval(map[string]any{})
fmt.Println(out)
}
Expected behavior
Each of the latter examples should result in an error from the timestamp()
function
Additional context
If compatibility is needed, I recommend we add an option in cel-go
to provide compatibility rather than forcing other implementations to replicate Golang's bugs.
Metadata
Metadata
Assignees
Labels
No labels