[T1601] FEAT: Automatically fill the Github PR URL upon PR creation - #1791
[T1601] FEAT: Automatically fill the Github PR URL upon PR creation#1791AlexandrePhilibert wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Introduces a new Odoo addon (project_task_github) that listens to GitHub Pull Request webhooks and automatically populates the task’s PR URI when the PR title (or branch name) starts with a task code like T1601.
Changes:
- Add a GitHub webhook controller that validates
X-Hub-Signature-256and processespull_requestopened/editedevents. - Add task lookup/linking helpers on
project.taskto find tasks by code and setpr_urionly when empty. - Add module documentation (usage + configuration) and addon manifest/init wiring.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| project_task_github/readme/USAGE.md | Documents how task codes in PR title/branch trigger PR URI auto-fill. |
| project_task_github/readme/DESCRIPTION.md | Describes module behavior and examples of supported PR/branch naming. |
| project_task_github/readme/CONFIGURE.md | Explains how to configure the GitHub webhook secret and org webhook settings. |
| project_task_github/models/project_task.py | Adds task-code extraction and PR URI linking helpers on project.task. |
| project_task_github/models/init.py | Exposes the new model extension. |
| project_task_github/controllers/github_webhook.py | Implements the webhook endpoint, signature verification, and linking flow. |
| project_task_github/controllers/init.py | Exposes the new controller. |
| project_task_github/manifest.py | Declares the addon, dependencies, and metadata. |
| project_task_github/init.py | Initializes controllers and models packages. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| try: | ||
| payload = json.loads(body) | ||
| except json.JSONDecodeError: | ||
| _logger.error( | ||
| "The body of GitHub delivery %s is not JSON. The content type " | ||
| "of the webhook must be set to application/json.", | ||
| delivery, | ||
| ) | ||
| return request.make_response("BAD_PAYLOAD", status=400) |
| @http.route( | ||
| "/github/webhook", | ||
| type="http", | ||
| auth="public", | ||
| methods=["POST"], | ||
| csrf=False, | ||
| save_session=False, | ||
| ) |
7eff833 to
5b10f5e
Compare
Confidence Score: 4/5One non-security P1 failure remains: editing a pull request’s task reference can create duplicate task-to-PR associations. The final scoring set has exactly one P1 finding and it is not security-related, which results in a confidence score of 4. Files Needing Attention: project_task_github/controllers/github_webhook.py
What T-Rex did
Reviews (2): Last reviewed commit: "[T1601] FIX: Typo" | Re-trigger Greptile |
| ) | ||
| return request.make_response("NO_TASK") | ||
|
|
||
| task._set_github_pr_uri(pull_request["html_url"]) |
There was a problem hiding this comment.
Edited pull requests retain the previous task link
When a pull request initially linked to task A is edited so its title or branch resolves to task B, this call adds the PR URL to B without removing it from A. Both tasks then remain associated with the same pull request. Before linking the newly resolved task, clear or reassign any existing holder of this URL.
Artifacts
Executable GitHub webhook reassociation harness
- A narrow authored harness imports the repository controller and model methods, signs realistic webhook payloads, and drives the opened-to-edited sequence, showing the changed path was executed.
Opened pull request webhook response before title retargeting
- The executed initial webhook request returned HTTP 200 OK and linked only T100 to the PR URL, establishing the pre-edit association.
Edited pull request webhook response after title retargeting
- The executed edited webhook request returned HTTP 200 OK but retained T100's URL and added the same URL to T200, confirming the stale duplicate association.
Python compilation of the harness and exercised source files
- The executed Python compilation command completed with exit code 0 for the harness, controller, and model source, confirming the exercised files parse successfully.
| ) | ||
| return request.make_response("NO_TASK") | ||
|
|
||
| task._set_github_pr_uri(pull_request["html_url"]) |
There was a problem hiding this comment.
Edited PR links are not reassigned
When an edited pull request changes from task A to task B, this assigns the URL to B but never removes the existing assignment from A. The PR can therefore remain linked to two tasks, producing incorrect task/PR associations. Reconcile existing holders of html_url before assigning it to the newly resolved task.
Artifacts
Authenticated edited-webhook reproduction harness
- This executable harness loads the repository’s actual webhook and task methods and submits the edited event with A already linked and B identified, demonstrating the duplicate-link condition.
Observed webhook reproduction output
- This captured output records exit code 0, 200 OK, and the final state where both A and B contain the same pull-request URL, confirming the finding.
Automatically fill the Github PR URL on tasks when PRs are opened.
This PR does not address the following points :