What Notifications Does Open Code Review Support? Gerrit Integration Guide
Open Code Review delegates notification control to Gerrit via the notify field in the ReviewInput object, defaulting to OWNER but supporting any standard Gerrit notification enum including ALL, NONE, CC, OWNER_REVERT, and ALL_REVERT.
Open Code Review is Alibaba's open-source CLI tool for automated code analysis. While the core engine focuses on detecting code issues, it relies on platform-specific integrations to deliver results. For teams using Gerrit, the tool constructs a Gerrit ReviewInput payload that includes a notify parameter determining exactly who receives email alerts about posted review comments.
Where Notification Settings Are Configured
Unlike standalone review tools that manage their own email queues, Open Code Review uses Gerrit's native notification system. The configuration resides in the Gerrit integration helper script rather than the core CLI.
The Gerrit Integration Script
In examples/gerrit_ci/post_review.py, the script constructs the ReviewInput payload at line 137. Here, the notify field is explicitly set to control notification delivery:
review = {
"message": truncate_message(summary),
"tag": "autogenerated:opencodereview",
"notify": "OWNER", # ← notification target
"omit_duplicate_comments": True,
"drafts": "KEEP",
}
This dictionary becomes the JSON body of the HTTP POST request to Gerrit's /changes/{change-id}/review endpoint. The notify key tells Gerrit exactly which users should receive an email notification about this review update.
Default Notification Behavior
By default, Open Code Review sets notify to "OWNER". This means only the change owner (the author of the commit under review) receives a notification when the automated review results are posted. This conservative default prevents spamming reviewers with automated messages while ensuring the author is informed of issues.
Supported Notification Types
The notification behavior is not limited to the change owner. Because Open Code Review uses standard Gerrit ReviewInput, it supports all notification enums defined by the Gerrit REST API.
The Gerrit Notify Enum
According to the Gerrit API specification implemented in the integration, the notify field accepts the following string values:
"NONE"– Suppress all notifications. No emails are sent."OWNER"– Notify only the change owner (the default used by Open Code Review)."ALL"– Notify the change owner and all current reviewers assigned to the change."CC"– Notify the change owner plus any users listed in the CC field of the change."OWNER_REVERT"– When posting a revert change, notify only the owner of the original change being reverted."ALL_REVERT"– When posting a revert, notify all reviewers and the owner of the original change.
Modifying Notification Settings
To change who receives notifications, edit examples/gerrit_ci/post_review.py and modify the value assigned to the notify key. For example, to notify all reviewers of issues found by Open Code Review:
# In examples/gerrit_ci/post_review.py, line 137
review["notify"] = "ALL"
Or to completely silence notifications for automated reviews:
review["notify"] = "NONE"
After modifying the script, subsequent runs that post to Gerrit will use the new notification setting.
Inspecting the ReviewInput Configuration
You can verify the exact notify value being sent to Gerrit by examining the constructed payload. The JSON sent to Gerrit will look like this when notify is set to ALL:
{
"message": "OpenCodeReview found 3 issue(s)…",
"tag": "autogenerated:opencodereview",
"notify": "ALL",
"omit_duplicate_comments": true,
"drafts": "KEEP",
"comments": {
"src/main/java/Example.java": [
{
"line": 42,
"message": "Potential null pointer dereference"
}
]
}
}
Summary
- Open Code Review does not implement proprietary notifications; it delegates to Gerrit's
ReviewInputsystem. - The notification setting is controlled in
examples/gerrit_ci/post_review.pyat line 137 via thenotifyfield. - The default value is
"OWNER", notifying only the change author. - Supported values include
"NONE","OWNER","ALL","CC","OWNER_REVERT", and"ALL_REVERT"as per Gerrit API specifications. - Teams can customize notification behavior by modifying the Python script before execution.
Frequently Asked Questions
Does Open Code Review send email notifications directly?
No. The tool posts review results to Gerrit, and Gerrit handles all email notifications based on the notify field in the ReviewInput payload. Open Code Review never sends emails directly to developers; it relies entirely on the Gerrit server's notification system.
How do I stop Open Code Review from spamming reviewers?
Set the notify value to "OWNER" (the default) to limit notifications to the change author only, or use "NONE" to suppress all notifications entirely. This is configured in examples/gerrit_ci/post_review.py by changing the value in the review dictionary.
Can I notify specific users or groups not covered by the standard options?
The standard Gerrit ReviewInput notify field only supports the enum values listed above. To notify specific additional users, you would need to add them to the change's CC list separately or modify the Gerrit project configuration, as the notify field does not accept arbitrary email addresses.
Is there a way to configure notifications per-project or per-branch?
Currently, the notification setting is hardcoded in the post_review.py helper script. To vary notifications by project or branch, you would need to modify the script to accept a command-line argument or environment variable for the notify value, then pass the appropriate value based on your CI/CD pipeline logic before calling the script.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →