-
Notifications
You must be signed in to change notification settings - Fork 43
fix: flagd not throwing parse error when target key is not a primitive #540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: flagd not throwing parse error when target key is not a primitive #540
Conversation
Signed-off-by: Kyle Julian <38759683+kylejuliandev@users.noreply.github.com>
Signed-off-by: Kyle Julian <38759683+kylejuliandev@users.noreply.github.com>
Signed-off-by: Kyle Julian <38759683+kylejuliandev@users.noreply.github.com>
Summary of ChangesHello @kylejuliandev, 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 refines the flag evaluation logic within the flagd provider to accurately detect and report invalid targeting configurations. By introducing explicit checks for primitive JsonLogic evaluation results and robust exception handling, it ensures that flags with malformed targeting rules, such as those using non-primitive keys, correctly trigger a ParseError. This enhancement improves the diagnostic capabilities and reliability of the flag resolution process. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly addresses an issue where invalid targeting rules in flagd were not producing a parse error. The added validation for the JsonLogic evaluation result is a good improvement. My review includes a suggestion to fix a bug in the handling of null evaluation results and to refactor the logic for better readability. I've also included a minor point about catching generic exceptions.
src/OpenFeature.Contrib.Providers.Flagd/Resolver/InProcess/JsonEvaluator.cs
Outdated
Show resolved
Hide resolved
src/OpenFeature.Contrib.Providers.Flagd/Resolver/InProcess/JsonEvaluator.cs
Show resolved
Hide resolved
Signed-off-by: Kyle Julian <38759683+kylejuliandev@users.noreply.github.com>
|
Could you please add a test to verify the new behaviour is what we expect? |
Yep will add it later today! It was late last night 😆 |
Signed-off-by: Kyle Julian <38759683+kylejuliandev@users.noreply.github.com>
This PR
JsonLogic returns the whole key even when the targeting hasn't been matched. For example,
invalidis the key but the targeting is not valid so the whole json string gets returned. This causes the provider to return a Flag not found response (although the flag has been found, the targeting is just invalid). I found this while adding support in the flagd e2e tests for the targeting.feature and found the provider not returning the correct response.{ "flags": { "error-targeting-flag": { "defaultVariant": "two", "state": "ENABLED", "targeting": { "invalid": [ "this is not valid targeting" ] }, "variants": { "one": 1, "two": 2 } } } }Related Issues
Notes
Follow-up Tasks
How to test