Conversation
Summary of ChangesHello @trojanc, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the FEEL expression evaluator to return native Go types from its primary evaluation functions. This change aims to enhance the usability and integration of the FEEL engine within Go applications by providing standard Go data structures and types directly, eliminating the need for manual unwrapping of custom FEEL types. The update also includes comprehensive test adjustments and a fix to ensure the TCK tests execute correctly, validating the new behavior. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request is a great step towards improving the library's usability by returning native Go types from EvalString and EvalStringWithScope. The changes are well-structured, with the core logic encapsulated in the new unwrapFEELValue function, and the test suite has been commendably updated to reflect these changes. However, I've identified a critical issue with how durations are handled and a high-severity issue regarding map key conversions, both of which could lead to silent data corruption. Addressing these points will be crucial for ensuring the reliability of the new API.
eval.go
Outdated
| case *FEELDuration: | ||
| return val.Duration() |
There was a problem hiding this comment.
Returning val.Duration() which is a time.Duration is problematic for year-month durations. time.Duration is a nanosecond count and cannot represent variable units like years and months. The current implementation of FEELDuration.Duration() ignores Years and Months fields, leading to silent data loss and incorrect results when evaluating year-month durations (e.g., duration("P1Y") would incorrectly result in a 0 duration). Consider returning *FEELDuration itself or another struct that can preserve the year and month components to avoid this data corruption.
There was a problem hiding this comment.
Not really sure what to do about this....
There was a problem hiding this comment.
worth another issue ... I will create one.
This PR attempts to address #3 and returns go types with
EvalStringandEvalStringWithScopeThis MR also adds a small fix to have tck tests run
Assumptions made:
[]anymap[string]anyfloat64get valuewill return the struct being referenced instead of a half baked map (mapstructuredoes unintended things....)