Bug 1997384 - Create a mapping table in the JiraWebhookSync extension the map jira ids to bug ids#2515
Conversation
… the map jira ids to bug ids
There was a problem hiding this comment.
Pull Request Overview
This PR adds functionality to intercept Jira see_also URLs and store them in a dedicated mapping table instead of as regular see_also links. This is a workaround for JBI design choices that require the see_also value to not exist to prevent duplicate Jira tickets.
Key changes:
- Introduces a new
jira_bug_mapdatabase table to store bug-to-Jira ticket mappings - Adds configuration parameter
jira_webhook_sync_project_keysto specify which Jira projects should use the mapping table - Intercepts see_also additions in
bug_start_of_updatehook and redirects configured Jira URLs to the mapping table - Modifies webhook payload to include Jira URLs from the mapping table
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| extensions/JiraWebhookSync/lib/JiraBugMap.pm | New module implementing the Jira-to-bug mapping object with validators and URL extraction logic |
| extensions/JiraWebhookSync/Extension.pm | Adds database schema, bug_start_of_update hook to intercept see_also, and webhook_before_send logic to inject mapped URLs |
| extensions/JiraWebhookSync/lib/Config.pm | Adds new configuration parameter for project keys with JSON validation |
| extensions/JiraWebhookSync/template/en/default/admin/params/jirawebhooksync.html.tmpl | Adds description for the new project keys parameter |
| extensions/JiraWebhookSync/template/en/default/global/user-error.html.tmpl | New template file defining error messages for Jira mapping validation failures |
| t/.perlcritic-history | Updates PerlCritic violation count for RequireArgUnpacking policy |
Comments suppressed due to low confidence (1)
extensions/JiraWebhookSync/lib/Config.pm:1
- The parameter description is missing a trailing comma after the closing quote, which is inconsistent with the pattern used in the
jira_webhook_sync_configparameter above (line 40).
# This Source Code Form is subject to the terms of the Mozilla Public
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
extensions/JiraWebhookSync/template/en/default/admin/params/jirawebhooksync.html.tmpl
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Match patterns like: | ||
| # - https://jira.example.com/PROJ-123 | ||
| # - https://jira.example.com/browse/PROJ-123 | ||
| # - https://jira.example.com/projects/PROJ/issues/PROJ-123 | ||
|
|
||
| my ($project_key, $jira_id); | ||
|
|
||
| if ($url->path =~ m{^/?([[:upper:]]+)-\d+$}) { | ||
|
|
||
| # Direct format: PROJ-123 | ||
| $jira_id = $url->path; | ||
| $project_key = $1; | ||
| } | ||
| elsif ($url->path =~ m{/browse/([[:upper:]]+-\d+)}) { | ||
|
|
||
| # URL format: /browse/PROJ-123 | ||
| $jira_id = $1; | ||
| ($project_key) = $jira_id =~ /^([[:upper:]]+)-/; | ||
| } | ||
| elsif ($url->path =~ m{/issues/([[:upper:]]+-\d+)}) { | ||
|
|
||
| # URL format: /issues/PROJ-123 | ||
| $jira_id = $1; | ||
| ($project_key) = $jira_id =~ /^([[:upper:]]+)-/; | ||
| } |
There was a problem hiding this comment.
Nit: this would go well in a separate function, where we could add a unit test for it.
external_test_api.pl
Outdated
| '/webhooks/last_payload' => sub { | ||
| my $c = shift; | ||
| my $data = $cache->{webhook_last_payload}; | ||
| my $data = delete $cache->{webhook_last_payload}; |
There was a problem hiding this comment.
What does this change do?
- Removed some patterns that were invalid anyway - Removed unnecessary deletion of last payload.
No description provided.