feat: graceful fallback to code default when no default variant resolved#1707
feat: graceful fallback to code default when no default variant resolved#1707leakonvalinka wants to merge 1 commit intoopen-feature:mainfrom
Conversation
Summary of ChangesHello, 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 enhances the flag evaluation process by introducing a more robust handling of default values. It ensures that if a flag evaluation results in a default variant but no specific default is configured, the system will now gracefully fall back to the code-provided default value instead of throwing an error. This change improves the resilience and predictability of flag evaluations, preventing unexpected failures in scenarios where flag configurations might be incomplete or misconfigured. Additionally, it includes an upgrade to the gRPC evaluation API to version 2, reflecting updates in the underlying flagd specification. Highlights
Changelog
Activity
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 correctly implements the feature to return the code's default value when a flag resolves to a default variant that doesn't exist, instead of throwing an error. The changes are consistently applied across both RPC and in-process resolvers, including updates to the gRPC v2 API. I've included a couple of suggestions to enhance code readability and follow modern Java best practices.
| new HashMap() { | ||
| { | ||
| put("service", "flagd.evaluation.v2.Service"); | ||
| } |
There was a problem hiding this comment.
While this follows the existing pattern in the file, using double-brace initialization is generally considered an anti-pattern in modern Java. It creates an anonymous inner class for each instance, which can have performance overhead and may lead to memory leaks if not used carefully. A better alternative is to use java.util.Collections.singletonMap().
java.util.Collections.singletonMap("service", "flagd.evaluation.v2.Service")There was a problem hiding this comment.
should we apply this? if so, i'd apply this to all the other maps too, ofc
There was a problem hiding this comment.
If it is really better, I would do it
...rs/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/rpc/RpcResolver.java
Outdated
Show resolved
Hide resolved
8c4ff54 to
23128f6
Compare
300c0a9 to
cf05eaf
Compare
3617e68 to
84eebf6
Compare
Signed-off-by: Konvalinka <lea.konvalinka@dynatrace.com> Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
84eebf6 to
9c47de0
Compare
This PR
Related Issues
#1704
Notes
Follow-up Tasks
How to test