Skip to content

Add EmojiEvent dispatcher support#382

Merged
flc1125 merged 2 commits into3.xfrom
feat-emoji-event-dispatcher
Mar 9, 2026
Merged

Add EmojiEvent dispatcher support#382
flc1125 merged 2 commits into3.xfrom
feat-emoji-event-dispatcher

Conversation

@flc1125
Copy link
Copy Markdown
Owner

@flc1125 flc1125 commented Mar 9, 2026

Summary

  • add dispatcher routing support for *gitlab.EmojiEvent
  • add EmojiListener registration and processing
  • add webhook fixture and tests for EmojiEvent dispatch

Testing

  • go test ./...

Summary by CodeRabbit

  • New Features

    • Added support for emoji award events in the dispatcher.
    • Introduced an EmojiListener interface and a public way to register emoji listeners so apps can handle emoji events.
  • Tests

    • Added comprehensive test coverage and a JSON fixture for emoji award webhook events.

Copilot AI review requested due to automatic review settings March 9, 2026 03:53
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 9, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 extends the existing webhook dispatcher to support EmojiEvent payloads from GitLab. It introduces the necessary interfaces, registration methods, and event processing logic to allow applications to listen for and react to emoji-related activities. The changes ensure that the system can correctly parse and route these new event types, enhancing its integration capabilities with GitLab's webhook system.

Highlights

  • EmojiEvent Dispatcher Support: Added routing support for *gitlab.EmojiEvent within the dispatcher mechanism.
  • EmojiListener Registration: Implemented EmojiListener registration and event processing capabilities.
  • Webhook Fixture and Tests: Included a new webhook fixture and corresponding tests to validate EmojiEvent dispatching.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • dispatcher.go
    • Added emojiListeners slice to the Dispatcher struct.
    • Updated RegisterListeners to automatically register EmojiListener implementations.
    • Introduced RegisterEmojiListener method for explicit registration.
    • Added a case for *gitlab.EmojiEvent in the Dispatch method to route emoji events.
    • Implemented processEmojiEvent to handle and fan out EmojiEvents to registered listeners.
  • dispatcher_test.go
    • Added a new test case for EmojiEvent in TestDispatcher_Dispatch to verify correct routing.
    • Included EmojiListener in the interface checks for testListener to ensure conformance.
    • Implemented the OnEmoji method within testListener to simulate emoji event handling during tests.
  • listeners.go
    • Defined the EmojiListener interface, requiring an OnEmoji method to process *gitlab.EmojiEvent.
  • testdata/webhooks/emoji.json
    • Added a new JSON fixture file containing a sample EmojiEvent payload for testing purposes.
Activity
  • No human activity has been recorded on this pull request yet.
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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 9, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: da727662-c771-4157-b302-d27dbc9200ca

📥 Commits

Reviewing files that changed from the base of the PR and between 1b76b72 and 3a382ba.

📒 Files selected for processing (1)
  • dispatcher_test.go

📝 Walkthrough

Walkthrough

Adds support for GitLab emoji award webhook events: new EmojiListener interface, registration and dispatch pathways in the dispatcher, a processing handler for *gitlab.EmojiEvent, tests exercising emoji dispatch, and a JSON fixture for emoji webhook payloads.

Changes

Cohort / File(s) Summary
Listener Interface
listeners.go
Added EmojiListener interface with OnEmoji(ctx context.Context, event *gitlab.EmojiEvent) error.
Dispatcher handler
dispatcher.go
Added emojiListeners []EmojiListener field, RegisterEmojiListener(...) method, processEmojiEvent handler, and Dispatch case for *gitlab.EmojiEvent routing to registered emoji listeners.
Tests
dispatcher_test.go, testdata/webhooks/emoji.json
Added emoji fixture and test case; implemented OnEmoji on test listener and registered EmojiListener to verify dispatching of emoji events.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Poem

🐰
I hopped through payloads, soft and spry,
A tiny thumbs-up passed me by,
I routed joy from web to ear,
Listeners woke — the cheer was clear,
Emojis hopped and stayed nearby 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add EmojiEvent dispatcher support' clearly and concisely summarizes the main change: introducing dispatcher support for emoji events, which is accurately reflected across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-emoji-event-dispatcher

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@flc1125 flc1125 linked an issue Mar 9, 2026 that may be closed by this pull request
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.55%. Comparing base (0e6b068) to head (3a382ba).
⚠️ Report is 1 commits behind head on 3.x.

Additional details and impacted files
@@            Coverage Diff             @@
##              3.x     #382      +/-   ##
==========================================
+ Coverage   92.27%   92.55%   +0.28%     
==========================================
  Files           1        1              
  Lines         207      215       +8     
==========================================
+ Hits          191      199       +8     
  Misses         11       11              
  Partials        5        5              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dosubot dosubot bot added the enhancement New feature or request label Mar 9, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class dispatch support for GitLab “Emoji” (award emoji) webhooks to the existing webhook dispatcher framework.

Changes:

  • Introduces EmojiListener and wires listener registration into the dispatcher.
  • Adds routing/processing for *gitlab.EmojiEvent in Dispatcher.Dispatch.
  • Adds an Emoji webhook fixture and extends dispatcher tests to cover Emoji event parsing + dispatch.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
testdata/webhooks/emoji.json Adds an award-emoji webhook payload fixture used by tests.
listeners.go Adds the EmojiListener interface to the listener set.
dispatcher.go Adds emoji listener storage, registration, dispatch routing, and processing.
dispatcher_test.go Extends dispatch test matrix and test listener with OnEmoji assertions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
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 adds support for GitLab EmojiEvent to the webhook dispatcher. The changes are consistent with the existing architecture, adding the necessary listener interface, registration logic, and event dispatching case. A test case with a webhook fixture is also included. While the changes are mostly correct, a critical concurrency bug was found in the underlying processEvent function that is called by the new code, which could lead to incorrect behavior when multiple listeners are registered. Additionally, an improvement to the new test case is suggested to make it more robust.

Comment on lines +335 to +337
func (d *Dispatcher) processEmojiEvent(ctx context.Context, event *gitlab.EmojiEvent) error {
return processEvent(ctx, d.emojiListeners, EmojiListener.OnEmoji, event)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This function calls processEvent, which contains a critical concurrency bug. The loop in processEvent that launches goroutines to handle listeners does not correctly capture the listener loop variable. This is a classic Go pitfall where all goroutines will share a reference to the same variable, which will hold the value of the last listener in the slice by the time they execute. This means if multiple listeners are registered, only the last one will be called, and it will be called multiple times.

While the code to fix is outside the diff, this is a critical issue affecting the correctness of this new event handler. The processEvent function needs to be fixed.

Here is how the loop in processEvent should be changed:

	for _, listener := range listeners {
		listener := listener // create a new variable for the closure
		go func() {
			defer wg.Done()
			if err := handler(listener, ctx, event); err != nil {
				errCh <- err
			}
		}()
	}

Comment on lines +139 to +141
testDispatcherContext(ctx, t.t)
assert.Equal(t.t, "awesome-project", event.Project.Name)
assert.Equal(t.t, "thumbsup", event.ObjectAttributes.Name)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The test assertions for the new EmojiEvent are minimal. To ensure the event payload is parsed correctly and improve test robustness, please consider adding assertions for other key fields from the ObjectAttributes, such as Action and AwardableType.

	testDispatcherContext(ctx, t.t)
	assert.Equal(t.t, "awesome-project", event.Project.Name)
	assert.Equal(t.t, "thumbsup", event.ObjectAttributes.Name)
	assert.Equal(t.t, "award", event.ObjectAttributes.Action)
	assert.Equal(t.t, "Issue", event.ObjectAttributes.AwardableType)

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@dispatcher_test.go`:
- Line 55: The new test-table entry {"emoji", gitlab.EventTypeEmoji,
"testdata/webhooks/emoji.json"} in dispatcher_test.go is not gofumpt-formatted;
run gofumpt (or gofmt -s) on dispatcher_test.go and commit the resulting changes
so the test table and surrounding code conform to gofumpt rules (fix spacing,
alignment, and any import/format adjustments) before merging.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1f4ae844-c363-46aa-9691-df3310493021

📥 Commits

Reviewing files that changed from the base of the PR and between 0e6b068 and 1b76b72.

📒 Files selected for processing (4)
  • dispatcher.go
  • dispatcher_test.go
  • listeners.go
  • testdata/webhooks/emoji.json

@flc1125 flc1125 merged commit 5e1db4e into 3.x Mar 9, 2026
11 checks passed
@flc1125 flc1125 deleted the feat-emoji-event-dispatcher branch March 9, 2026 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support dispatcher routing for EmojiEvent

2 participants