Skip to content

fix: RPC event serialization error, dont send empty messages#1871

Merged
toddbaert merged 1 commit intoopen-feature:mainfrom
karel1980:bugfix/sending-notifications
Mar 4, 2026
Merged

fix: RPC event serialization error, dont send empty messages#1871
toddbaert merged 1 commit intoopen-feature:mainfrom
karel1980:bugfix/sending-notifications

Conversation

@karel1980
Copy link
Contributor

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

@karel1980 karel1980 requested review from a team as code owners February 16, 2026 10:02
@netlify
Copy link

netlify bot commented Feb 16, 2026

Deploy Preview for polite-licorice-3db33c canceled.

Name Link
🔨 Latest commit c8b1e4d
🔍 Latest deploy log https://app.netlify.com/projects/polite-licorice-3db33c/deploys/69a82b249e59ef0007d9224d

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Feb 16, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 nil during conversion to a Protobuf struct. The changes introduce robust nil checks before conversion and enhance the notification handling logic, ensuring stability and reliability of event streams. A new test has also been added to validate the correct behavior of notification data conversion.

Highlights

  • Bug Fix: Nil Notification Data Panic: Implemented a fix to prevent panics when notification.Data is nil during structpb.NewStruct conversion within the event stream handlers for both OldFlagEvaluationService and FlagEvaluationService.
  • New Test Case for Notification Data Conversion: Introduced a new test case (TestNotificationDataStructpbConversion) to validate the successful conversion of notification data to structpb.Struct without errors, ensuring robustness.
  • Refactored Notification Data Handling: Adjusted type assertions and conversions in notification handling logic within connect_service_test.go and eventing.go for improved type safety and consistency across the codebase.
Changelog
  • flagd/pkg/service/flag-evaluation/connect_service_test.go
    • Removed an unused import for notifications.
    • Updated the type assertion for notification data from notifications.Notifications to map[string]interface{}.
  • flagd/pkg/service/flag-evaluation/eventing.go
    • Added an explicit type conversion map[string]interface{}(notifications) when assigning notification data.
  • flagd/pkg/service/flag-evaluation/eventing_test.go
    • Imported google.golang.org/protobuf/types/known/structpb.
    • Added TestNotificationDataStructpbConversion to verify that iservice.Notification data can be converted to structpb.Struct without errors.
  • flagd/pkg/service/flag-evaluation/flag_evaluator.go
    • Introduced a nil check for notification.Data before attempting structpb.NewStruct conversion to prevent panics.
  • flagd/pkg/service/flag-evaluation/flag_evaluator_v2.go
    • Introduced a nil check for notification.Data before attempting structpb.NewStruct conversion to prevent panics.
Activity
  • The author identified a notification error that could lead to panics and implemented a fix.
  • A new test was added to reproduce and verify the fix for the identified notification error.
  • Manual testing was performed by the author to confirm the problem was resolved.
  • The author encourages feedback on the solution's technical aspects or fit within the codebase.
  • The author suggests running the test suite to verify the changes.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@karel1980 karel1980 changed the title Bugfix/sending notifications fix: error when sending notifications Feb 16, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 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.

@karel1980
Copy link
Contributor Author

Changed the PR title (conventional commit)

@karel1980 karel1980 force-pushed the bugfix/sending-notifications branch from 21a5fbe to 21f04d3 Compare February 16, 2026 18:28
@toddbaert toddbaert changed the title fix: error when sending notifications fix: error when sending notifications without changes Mar 4, 2026
@toddbaert
Copy link
Member

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 an error that occurred when sending notifications, by ensuring the notification data is a plain map[string]interface{} which is compatible with protobuf serialization. The change is correct and is accompanied by a regression test. I've added a couple of suggestions to further improve the code: one to avoid sending empty notifications, and another to improve test reliability by avoiding time.Sleep.

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Mar 4, 2026
@toddbaert toddbaert changed the title fix: error when sending notifications without changes fix: serialization error; don't send empty notifications Mar 4, 2026
@toddbaert toddbaert changed the title fix: serialization error; don't send empty notifications fix: RPC event serialization error, dont send empty messages Mar 4, 2026
@toddbaert toddbaert force-pushed the bugfix/sending-notifications branch 2 times, most recently from 07ea2ab to 90bde21 Compare March 4, 2026 12:32
@toddbaert
Copy link
Member

toddbaert commented Mar 4, 2026

@karel1980 I made a change here to avoid sending empty notification messages entirely. If no flags are changed, there doesn't seem to be a point. I don't think this happens much in prod scenarios, to be honest.

We no longer send notifications which are empty.

Signed-off-by: Karel Vervaeke <karel@vervaeke.info>
@toddbaert toddbaert force-pushed the bugfix/sending-notifications branch from 90bde21 to c8b1e4d Compare March 4, 2026 12:52
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 4, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
41.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@toddbaert toddbaert merged commit 95d38fd into open-feature:main Mar 4, 2026
16 of 17 checks passed
@github-actions github-actions bot mentioned this pull request Mar 4, 2026
toddbaert pushed a commit that referenced this pull request Mar 4, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>flagd: 0.14.1</summary>

##
[0.14.1](flagd/v0.14.0...flagd/v0.14.1)
(2026-03-04)


### 🐛 Bug Fixes

* RPC event serialization error, dont send empty messages
([#1871](#1871))
([95d38fd](95d38fd))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Signed-off-by: OpenFeature Bot <109696520+openfeaturebot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants