fix: error when sending notifications#1871
fix: error when sending notifications#1871karel1980 wants to merge 2 commits intoopen-feature:mainfrom
Conversation
✅ Deploy Preview for polite-licorice-3db33c canceled.
|
Summary of ChangesHello @karel1980, 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 addresses a critical bug where the flag evaluation service could panic if a notification's data payload was 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 effectively addresses a bug in notification sending by ensuring the data structure is correctly typed before protobuf conversion. The inclusion of a new test case to validate the fix is a great example of test-driven development. Additionally, the changes improve the robustness of the event stream handling by preventing potential panics from nil data and refining error management. I've included a couple of minor suggestions to enhance code readability in the event stream handlers.
| var err error | ||
| d, err = structpb.NewStruct(notification.Data) | ||
| if err != nil { | ||
| s.logger.Error(err.Error()) | ||
| continue | ||
| } |
There was a problem hiding this comment.
For better readability and to follow a more common Go idiom, you can use a short variable declaration (:=) inside the if block. This avoids the need for var err error and makes the code slightly more concise.
| var err error | |
| d, err = structpb.NewStruct(notification.Data) | |
| if err != nil { | |
| s.logger.Error(err.Error()) | |
| continue | |
| } | |
| s, err := structpb.NewStruct(notification.Data) | |
| if err != nil { | |
| s.logger.Error(err.Error()) | |
| continue | |
| } | |
| d = s |
| var err error | ||
| d, err = structpb.NewStruct(notification.Data) | ||
| if err != nil { | ||
| s.logger.Error(err.Error()) | ||
| continue | ||
| } |
There was a problem hiding this comment.
For better readability and to follow a more common Go idiom, you can use a short variable declaration (:=) inside the if block. This avoids the need for var err error and makes the code slightly more concise.
| var err error | |
| d, err = structpb.NewStruct(notification.Data) | |
| if err != nil { | |
| s.logger.Error(err.Error()) | |
| continue | |
| } | |
| s, err := structpb.NewStruct(notification.Data) | |
| if err != nil { | |
| s.logger.Error(err.Error()) | |
| continue | |
| } | |
| d = s |
|
Changed the PR title (conventional commit) |
the error: invalid type: notifications.Notifications {"component": "flagd.evaluation.v1"}
the discussion: open-feature#1869
Signed-off-by: Karel Vervaeke <karel@vervaeke.info>
Signed-off-by: Karel Vervaeke <karel@vervaeke.info>
21a5fbe to
21f04d3
Compare
|



This PR
Related Issues
None that I'm aware of
Notes
vibe coding warning: I don't know go well enough to fix this, but I did use TDD and also did a manual test to verify that my problem went away.
If any part of my solution is technicaly or doesn't fit in the codebase for any reason: feel free to comment, I'll do my best to improve it.
How to test
Running the test suite should be sufficient