-
Notifications
You must be signed in to change notification settings - Fork 0
fix(pr-reviewer): resolve PR author from sender login #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+146
−66
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -176,12 +176,12 @@ function reviewAuthorAllowlist(ctx: WorkforceCtx): Set<string> { | |||||
| export function reviewAuthorAllowlistDecision( | ||||||
| allow: Set<string>, | ||||||
| author: string | ||||||
| ): { reason: string } | null { | ||||||
| ): { reason: string; notify?: boolean } | null { | ||||||
| if (allow.size === 0) { | ||||||
| return null; | ||||||
| } | ||||||
| if (!author || author === 'unknown') { | ||||||
| return { reason: 'REVIEW_AUTHORS is set but the PR author could not be resolved' }; | ||||||
| return { reason: 'REVIEW_AUTHORS is set but the PR author could not be resolved', notify: true }; | ||||||
| } | ||||||
| if (!allow.has(author)) { | ||||||
| return { reason: `author @${author} is not in REVIEW_AUTHORS` }; | ||||||
|
|
@@ -311,6 +311,7 @@ export function readPr(payload: unknown): Pr | undefined { | |||||
| }; | ||||||
| check_run?: { pull_requests?: Array<{ number?: number; html_url?: string; head_sha?: string }> }; | ||||||
| repository?: { name?: string; owner?: { login?: string } }; | ||||||
| sender?: { login?: string }; | ||||||
| } | null; | ||||||
| const prRef = p?.pull_request ?? p?.check_run?.pull_requests?.[0]; | ||||||
| const number = prRef?.number ?? p?.number; | ||||||
|
|
@@ -324,7 +325,7 @@ export function readPr(payload: unknown): Pr | undefined { | |||||
| repo, | ||||||
| number, | ||||||
| url: prRef?.html_url ?? `https://github.com/${owner}/${repo}/pull/${number}`, | ||||||
| author: p?.pull_request?.user?.login ?? 'unknown', | ||||||
| author: p?.pull_request?.user?.login ?? (p?.pull_request ? p?.sender?.login : undefined) ?? 'unknown', | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Author fallback to Prompt for AI agents
Suggested change
|
||||||
| ...(headSha ? { headSha } : {}), | ||||||
| ...(p?.pull_request?.state ? { state: p.pull_request.state } : {}), | ||||||
| ...(typeof p?.pull_request?.merged === 'boolean' ? { merged: p.pull_request.merged } : {}), | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Falling back to
sender.loginfor every payload that containspull_requestcan misidentify the PR author on review/comment events, wheresenderis often the reviewer/commenter rather than the opener. If PR metadata is temporarily unavailable, the allowlist check can be evaluated against the wrong user, causing incorrect authorization decisions. Restrict this fallback to event types wheresenderis guaranteed to be the PR opener, or leave the author unresolved otherwise. [security]Severity Level: Major⚠️
Steps of Reproduction ✅
Fix in Cursor | Fix in VSCode Claude
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖