Skip to content

fix(pagerduty): join incident assignments and users within the connection - #9423

Open
ShivamSharma43 wants to merge 1 commit into
apache:mainfrom
ShivamSharma43:fix/pagerduty-assignment-connection
Open

ShivamSharma43 wants to merge 1 commit into
apache:mainfrom
ShivamSharma43:fix/pagerduty-assignment-connection

Conversation

@ShivamSharma43

Copy link
Copy Markdown
Contributor

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.

convertIncidents selects the incidents of one connection and service, but joined _tool_pagerduty_assignments only on pa.incident_number = pi.number and _tool_pagerduty_users only on pa.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 extra issue_assignees rows, and issues.assignee_id/assignee_name became 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 on pa.connection_id = pi.connection_id as well, and users on pu.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 run convertIncidents for connection 1 and check issues and issue_assignees against 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, and issue_assignees has 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/ with E2E_DB_URL pointing to a local PostgreSQL 18: pass (and fails without the converter change, as described above).
  • go build ./plugins/pagerduty/..., gofmt and golangci-lint run ./plugins/pagerduty/... (--tests=false, plus the e2e package with tests): clean. I didn't run plugins/pagerduty/tasks tests, which need the generated mockery mocks; they don't cover the converter.
  • No open PR or issue touches the PagerDuty incident converter.
  • Not changed here: the _tool_pagerduty_assignments primary key is (user_id, incident_number) without connection_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.
  • Suggested label: pr-type/bug-fix.
  • AI assistance disclosure: this change was prepared with the help of Claude Code (Claude Opus 5.5), and I reviewed the diff. The commit carries a Co-Authored-By: trailer per the ASF generative tooling guidance.

🤖 Generated with Claude Code

…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>
Copilot AI balanced review requested due to automatic review settings November 20, 2026 15:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.

[Bug][PagerDuty] Incident assignees are joined across connections by incident number

2 participants