Skip to content

KAFKA-20362: Auto-fill PR reviewers in PR description#21928

Merged
chia7712 merged 2 commits intoapache:trunkfrom
mingyen066:KAFKA-20362-auto-add-reviewer
Apr 4, 2026
Merged

KAFKA-20362: Auto-fill PR reviewers in PR description#21928
chia7712 merged 2 commits intoapache:trunkfrom
mingyen066:KAFKA-20362-auto-add-reviewer

Conversation

@mingyen066
Copy link
Copy Markdown
Collaborator

@mingyen066 mingyen066 commented Apr 1, 2026

When a pull request submit review event is triggered (comment,
request changes, or approval), this change automatically adds the
reviewer to the Reviewers trailer in the PR body.

Note that comment will NOT trigger the auto-fill process.

This eliminates the need to manually run committer-tools/reviewers.py
before merging. The reviewer's name and email are resolved from their
most recent commit in the repo, falling back to their GitHub profile.

Changes:

  • pr-reviewed.yml: save reviewer login to artifact on review events
  • pr-linter.yml: pass reviewer login to pr-format.py
  • pr-format.py: resolve reviewer identity via GitHub API and append
    to the Reviewers trailer using git interpret-trailers

Testing:

$ python -c "
from importlib.machinery import SourceFileLoader
m = SourceFileLoader('pr_format',
'.github/scripts/pr-format.py').load_module()
print(m.resolve_reviewer('mingyen066'))
print(m.resolve_reviewer('antirez'))
print(m.resolve_reviewer('torvalds'))
"
# Tier 1 hit: found name and email from repo commit history
('Ming-Yen Chung', 'mingyen066@gmail.com')
# Tier 1 miss, Tier 2 hit: found email from GitHub profile
('Salvatore Sanfilippo', 'antirez@gmail.com')
# Both miss email: placeholder used for committer to fix manually
('Linus Torvalds', 'torvalds-email-not-found')

$ python -c " from importlib.machinery import SourceFileLoader m =
SourceFileLoader('pr_format',
'.github/scripts/pr-format.py').load_module() existing = ['Chia-Ping
Tsai <chia7712@gmail.com>, Ming-Yen Chung <mingyen066@gmail.com>']
print(m.already_exists('chia7712@gmail.com', existing))
print(m.already_exists('someone@gmail.com', existing))
print(m.already_exists('Chia7712@Gmail.com', existing)) " True False
True

$ python -c " from importlib.machinery import SourceFileLoader m =
SourceFileLoader('pr_format',
'.github/scripts/pr-format.py').load_module() body = 'This is a PR
description.\n' result = m.update_reviewers_trailer(body, 'Reviewers:
Alice <alice@test.com>') print(result) " This is a PR description.

Reviewers: Alice <alice@test.com>

Reviewers: TaiJuWu tjwu1217@gmail.com, Chia-Ping Tsai
chia7712@gmail.com

@github-actions github-actions bot added build Gradle build or GitHub Actions small Small PRs triage PRs from the community labels Apr 1, 2026
return email.lower() in [e.lower() for e in existing_emails]


def update_reviewers_trailer(body: str, trailer: str) -> str:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what happens if there are two reviewers adding the comment concurrently?

Copy link
Copy Markdown
Collaborator Author

@mingyen066 mingyen066 Apr 2, 2026

Choose a reason for hiding this comment

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

Each review comment triggers an independent pr-reviewed workflow run with its own workflow_run.id, so pr-format.py correctly receives each reviewer's login separately via its own artifact. The only possible race condition is if two pr-format.py runs read and update the PR body at the same time — the second write could overwrite the first, losing a reviewer. The race window is only between reading the PR body and writing it back in pr-format.py, which is a short window. Even if it does happen, the lost reviewer will be re-added on their next review comment. If we want to eliminate this entirely, we can add a concurrency group to pr-linter.yml to serialize runs per PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess the worst that happens is an unlucky reviewer gets dropped?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

that's right.

@mingyen066
Copy link
Copy Markdown
Collaborator Author

mingyen066 commented Apr 2, 2026

I've tested in my fork. It works well
mingyen066#4

@github-actions github-actions bot removed the triage PRs from the community label Apr 2, 2026
@chia7712 chia7712 merged commit ff64569 into apache:trunk Apr 4, 2026
27 checks passed
nileshkumar3 pushed a commit to nileshkumar3/kafka that referenced this pull request Apr 15, 2026
When a pull request **submit review** event is triggered (comment,
request changes,  or  approval), this change automatically adds the
reviewer to the  Reviewers  trailer in the PR body.

Note that **comment** will **NOT** trigger the auto-fill process.

This eliminates the need to manually run committer-tools/reviewers.py
before merging. The reviewer's name and email are resolved from their
most recent commit in the repo, falling back to their GitHub profile.

Changes:
- pr-reviewed.yml: save reviewer login to artifact on review events
- pr-linter.yml: pass reviewer login to pr-format.py
- pr-format.py: resolve reviewer identity via GitHub API and append
  to the Reviewers trailer using git interpret-trailers

Testing:

```
$ python -c "
from importlib.machinery import SourceFileLoader
m = SourceFileLoader('pr_format',
'.github/scripts/pr-format.py').load_module()
print(m.resolve_reviewer('mingyen066'))
print(m.resolve_reviewer('antirez'))
print(m.resolve_reviewer('torvalds'))
"
# Tier 1 hit: found name and email from repo commit history
('Ming-Yen Chung', 'mingyen066@gmail.com')
# Tier 1 miss, Tier 2 hit: found email from GitHub profile
('Salvatore Sanfilippo', 'antirez@gmail.com')
# Both miss email: placeholder used for committer to fix manually
('Linus Torvalds', 'torvalds-email-not-found')

$ python -c " from importlib.machinery import SourceFileLoader m =
SourceFileLoader('pr_format',
'.github/scripts/pr-format.py').load_module() existing = ['Chia-Ping
Tsai <chia7712@gmail.com>, Ming-Yen Chung <mingyen066@gmail.com>']
print(m.already_exists('chia7712@gmail.com', existing))
print(m.already_exists('someone@gmail.com', existing))
print(m.already_exists('Chia7712@Gmail.com', existing)) " True False
True

$ python -c " from importlib.machinery import SourceFileLoader m =
SourceFileLoader('pr_format',
'.github/scripts/pr-format.py').load_module() body = 'This is a PR
description.\n' result = m.update_reviewers_trailer(body, 'Reviewers:
Alice <alice@test.com>') print(result) " This is a PR description.

Reviewers: Alice <alice@test.com>
```

Reviewers: TaiJuWu <tjwu1217@gmail.com>, Chia-Ping Tsai
 <chia7712@gmail.com>
@mjsax
Copy link
Copy Markdown
Member

mjsax commented Apr 20, 2026

I just notice that we get Reviewers filled in automatically, but I find it not helpful at this point. It's does never use the correct email address. -- Can we fix this? If not, I would rather not have this action at all (at this point, I find it personally very annoying TBH).

For example:
Screenshot 2026-04-20 at 1 17 30 PM

This is not helpful at all. I need to update this manually anyway.

@mingyen066
Copy link
Copy Markdown
Collaborator Author

@mjsax Sorry for the noise. I'll fix it right away.

@mingyen066
Copy link
Copy Markdown
Collaborator Author

mingyen066 commented Apr 20, 2026

@mjsax Thanks for the feedback! Opened #22108 to skip the auto-fill when no reliable email can be resolved. Hope it's more helpful next time 😅

@chia7712
Copy link
Copy Markdown
Member

@UladzislauBlok Out of curiosity—since your email is hidden on your GitHub profile, are you okay with using your real email for the commit message? I know we can find it in your commit history anyway, but I wanted to check if you'd prefer to keep it private

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Gradle build or GitHub Actions small Small PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants