-
Notifications
You must be signed in to change notification settings - Fork 43
fix(flagd): Flag metadata not being mapped when using RpcResolver #575
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
base: main
Are you sure you want to change the base?
fix(flagd): Flag metadata not being mapped when using RpcResolver #575
Conversation
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 resolves a previously unaddressed issue in the Flagd Provider where flag metadata, although available from the Flagd service via RPC, was not being properly extracted and included in the 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 fixes a bug where flag metadata was not being mapped when using the RpcResolver. The changes correctly add metadata mapping to all flag resolution methods (ResolveBooleanValueAsync, ResolveStringValueAsync, etc.) by introducing a BuildFlagMetadata helper method. This new method processes the metadata from the gRPC response, supporting string, boolean, and number types while ignoring others, as described.
The implementation is solid and is accompanied by a comprehensive set of tests that verify the new functionality across all supported flag types and metadata value types.
I've provided a couple of suggestions to improve code consistency and test readability. Overall, this is a great contribution that addresses an important gap in functionality.
src/OpenFeature.Contrib.Providers.Flagd/Resolver/Rpc/RpcResolver.cs
Outdated
Show resolved
Hide resolved
test/OpenFeature.Contrib.Providers.Flagd.Test/Resolver/Rpc/RpcResolverTests.cs
Show resolved
Hide resolved
Signed-off-by: Kyle Julian <38759683+kylejuliandev@users.noreply.github.com>
askpt
left a comment
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.
Very minor comment. Just a nitpick
src/OpenFeature.Contrib.Providers.Flagd/Resolver/Rpc/RpcResolver.cs
Outdated
Show resolved
Hide resolved
Signed-off-by: Kyle Julian <38759683+kylejuliandev@users.noreply.github.com>
|
|
||
| [Theory] | ||
| [MemberData(nameof(ResolveValueFlagdMetadata))] | ||
| internal async Task ResolveValueAsync_AddsFlagMetadata<T>(Func<RpcResolver, Task<ResolutionDetails<T>>> act, |
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.
thought: I wonder if the tests would be cleaner and more understandable if I separated them out into ResolveStringValueAsync and ResolveBooleanValueAsync which all check the flag metadata is added?
I think the test theory is nice but probably makes it hard to follow. Thoughts?
| } | ||
| } | ||
|
|
||
| return items.Count > 0 ? new ImmutableMetadata(items) : null; |
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.
Do we want to return null, or an empty Metadata object?
| { "key3", Google.Protobuf.WellKnownTypes.Value.ForBool(true) }, | ||
| { "key4", Google.Protobuf.WellKnownTypes.Value.ForBool(false) }, | ||
| { "key5", Google.Protobuf.WellKnownTypes.Value.ForNumber(1) }, | ||
| { "key6", Google.Protobuf.WellKnownTypes.Value.ForNumber(3.14) }, |
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.
Please also add a test case for a really large number
This PR
Fixes an issue with the Flagd Provider not mapping Flag Metadata when using the RpcResolver. It looks like this was missed during the initial implementation, or it wasn't available at the time. Now metadata will be mapped for all types of flags when using the RpcResolver. Only strings, booleans, and numbers (integer/float/double) metadata types are supported - the rest are ignored.
Related Issues
Fixes #521
Notes
Follow-up Tasks
How to test