Skip to content

Add GitHub API functionality to assign PRs back to creators when violations are found#58

Merged
slavingia merged 1 commit intomainfrom
devin/1755701209-github-pr-assignment
Aug 20, 2025
Merged

Add GitHub API functionality to assign PRs back to creators when violations are found#58
slavingia merged 1 commit intomainfrom
devin/1755701209-github-pr-assignment

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

Add GitHub API functionality to assign PRs back to creators when violations are found

Summary

This PR implements automatic PR assignment functionality that assigns pull requests back to their creators when the AI analysis determines that the PR violates contributing guidelines. When Jacquez detects clear violations during the initial review process, it will now:

  1. Post a moderation comment (existing behavior)
  2. NEW: Automatically assign the PR back to the creator so they know to address the violations

The assignment uses the GitHub API endpoint POST /repos/{owner}/{repo}/issues/{issue_number}/assignees and only triggers when response.comment_needed is true (meaning the AI found clear guideline violations).

Review & Testing Checklist for Human

  • Verify GitHub App permissions - Confirm the Jacquez GitHub App has sufficient permissions to assign users to PRs in target repositories
  • End-to-end testing - Test with a real PR that violates guidelines to ensure assignment actually works (I couldn't test this locally)
  • Verify timing and workflow - Confirm that assigning immediately after posting violation comments is the correct timing for the intended workflow
  • Test edge cases - Try scenarios like: user already assigned, user without repository access, assignment on bot PRs (should be skipped)

Recommended test plan: Create a test PR that intentionally violates contributing guidelines in a repository where Jacquez is installed, then verify both the comment and assignment occur correctly.


Diagram

%%{ init : { "theme" : "default" }}%%
graph TD
    webhook["app/api/webhook/<br/>route.ts"]:::major-edit
    handlePR["handlePullRequestOpened()<br/>function"]:::major-edit
    ai["generateFriendlyResponse()<br/>(AI analysis)"]:::context
    github["GitHub API<br/>POST /issues/assignees"]:::major-edit
    
    webhook --> handlePR
    handlePR --> ai
    ai --> |"comment_needed = true"| github
    
    subgraph Legend
        L1["Major Edit"]:::major-edit
        L2["Minor Edit"]:::minor-edit  
        L3["Context/No Edit"]:::context
    end
    
    classDef major-edit fill:#90EE90
    classDef minor-edit fill:#87CEEB
    classDef context fill:#FFFFFF
Loading

Notes

  • The assignment logic is wrapped in try-catch to prevent webhook failures if assignment fails
  • Bot PRs are already filtered out earlier in the function, so no additional bot checks needed
  • Error handling follows existing patterns in the codebase for consistency
  • Only occurs when AI analysis determines clear violations (not for minor issues)

Link to Devin run: https://app.devin.ai/sessions/735a181caabd478a9ef93d22fc28f4bd
Requested by: Sahil Lavingia (@slavingia)

…ations are found

- Automatically assigns pull requests back to their creators after AI analysis determines violations of contributing guidelines
- Uses GitHub API endpoint POST /repos/{owner}/{repo}/issues/{issue_number}/assignees
- Only triggers when response.comment_needed is true (clear violations found)
- Includes proper error handling that doesn't break webhook if assignment fails
- Follows existing logging patterns for consistency
- Preserves existing webhook processing and AI review workflow

Co-Authored-By: Sahil Lavingia <sahil@gumroad.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Aug 20, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
jacquez Ready Ready Preview Comment Aug 20, 2025 2:51pm

@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@slavingia slavingia merged commit 62dd74f into main Aug 20, 2025
4 checks passed
@slavingia slavingia deleted the devin/1755701209-github-pr-assignment branch August 20, 2025 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant