Repository navigation
fix(pagerduty): join incident assignments and users within the connection - #9423
Open
ShivamSharma43 wants to merge 1 commit into
Open
ShivamSharma43 wants to merge 1 commit into
ShivamSharma43 wants to merge 1 commit into
Conversation
…tion convertIncidents joined _tool_pagerduty_assignments on the incident number only and _tool_pagerduty_users on the user id only. Incident numbers are per PagerDuty account, so with more than one connection an incident also picked up the assignments, and the assignee, of the incident with the same number in another connection. Join both tables on the incident's connection id as well. The e2e test now adds assignments and users of a second connection before converting connection 1, and checks they don't change its issues and issue assignees. Fixes apache#9422 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The PagerDuty incident converter joined assignments and users across connections, so an incident could get the assignees of another PagerDuty account's incident with the same number.
convertIncidentsselects the incidents of one connection and service, but joined_tool_pagerduty_assignmentsonly onpa.incident_number = pi.numberand_tool_pagerduty_usersonly onpa.user_id = pu.id. Incident numbers are per PagerDuty account, and both tables hold the rows of every connection. With two connections, incident #5 of connection 1 also matched the assignments of incident #5 of connection 2, so it got extraissue_assigneesrows, andissues.assignee_id/assignee_namebecame the other account's user whenever that assignment was newer (the converter keeps the latest one). A user id stored under two connections also returned one row per connection. Details in #9422.Changes:
tasks/incidents_converter.go: join assignments onpa.connection_id = pi.connection_idas well, and users onpu.connection_id = pa.connection_id.e2e/incident_test.go: after extracting connection 1, add assignments of connection 2 for incident numbers 5 and 6, their users, and a connection 2 user with the same id as a connection 1 assignee (P25K520), then runconvertIncidentsfor connection 1 and checkissuesandissue_assigneesagainst the existing snapshots. Without the fix the test fails: incident 6 (no assignee) gets the connection 2 user, incident 5's assignee becomes the connection 2 user, incident 4's assignee name comes from connection 2, andissue_assigneeshas 5 rows instead of 3.No schema or snapshot CSV changes.
Does this close any open issues?
Fixes #9422
Screenshots
N/A
Other Information
go test ./plugins/pagerduty/e2e/withE2E_DB_URLpointing to a local PostgreSQL 18: pass (and fails without the converter change, as described above).go build ./plugins/pagerduty/...,gofmtandgolangci-lint run ./plugins/pagerduty/...(--tests=false, plus the e2e package with tests): clean. I didn't runplugins/pagerduty/taskstests, which need the generated mockery mocks; they don't cover the converter._tool_pagerduty_assignmentsprimary key is(user_id, incident_number)withoutconnection_id. Since PagerDuty user ids are distinct across accounts this only matters when two connections point at the same account; it would need a migration, so I left it out.pr-type/bug-fix.Co-Authored-By:trailer per the ASF generative tooling guidance.🤖 Generated with Claude Code