Skip to content

fix(linker): scope clearHistoryData to current project only (#8814)#8815

Open
danielemoraschi wants to merge 1 commit intoapache:mainfrom
danielemoraschi:fix/linker-clear-history-data-scope-8814
Open

fix(linker): scope clearHistoryData to current project only (#8814)#8815
danielemoraschi wants to merge 1 commit intoapache:mainfrom
danielemoraschi:fix/linker-clear-history-data-scope-8814

Conversation

@danielemoraschi
Copy link
Copy Markdown

⚠️ Pre Checklist

  • I have read through the Contributing Documentation.
  • I have added relevant tests.
  • I have added relevant documentation.
  • I will add labels to the PR, such as pr-type/bug-fix, pr-type/feature-development, etc.

Summary

Fixes clearHistoryData() in the linker plugin which was deleting all pull_request_issues records instead of only the current project's linker-created rows.

Root cause: The function used a LEFT JOIN with project_name in the ON clause. With a LEFT JOIN, unmatched rows still appear in the result, so the subquery returned every PR ID in the system effectively wiping the entire pull_request_issues table on every linker run.

Impact: When two projects share a GitHub repo, running the pipeline for one project deleted all PR-issue links created by the other project's pipeline (and links from the GitHub converter).

Fix:

  • INNER JOIN + WHERE for project_name (fixes the LEFT JOIN bug)
  • Issue-side subquery scoped to current project's boards (prevents cross-project deletion)
  • _raw_data_table / _raw_data_remark filter to only delete linker-created rows (preserves GitHub converter rows)

Tests:

  • Added TestLinkPrToIssueWithSharedRepo e2e test with CSV fixtures simulating two projects sharing a repo
  • Verifies that running the linker for one project correctly creates its links, deletes its stale links, and preserves the other project's linker links and converter links
  • Existing TestLinkPrToIssue continues to pass unchanged

Does this close any open issues?

Closes #8814

Screenshots

N/A — backend-only change.

Other Information

The bug was introduced in commit a4cb023ba (May 2024, "Clear history data when running linker"). The existing e2e test did not catch it because it only covered a single project and flushed the table before running.

One edge case:
If an issue is removed from a project's board between two linker runs, the old stale link for that issue won't be cleaned up (because the issue-side subquery no longer matches it). But this matches how the creation logic works, it also scopes to current board state. And the old code had the same conceptual issue (it just masked it by deleting everything).

Opening this PR since this issue is a blocker for my setup.

)

The clearHistoryData() function used a LEFT JOIN with project_name
in the ON clause, causing the subquery to return all PR IDs regardless
of project. This effectively wiped the entire pull_request_issues table
on every linker run, deleting links from other projects sharing the
same repos and links created by the GitHub converter.

Fix:
- Use INNER JOIN + WHERE for proper project scoping
- Add issue-side subquery scoped to current project's boards
- Filter by _raw_data_table/_raw_data_remark to only delete
  linker-created rows

Add e2e test for cross-project shared repo scenario.
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. component/plugins This issue or PR relates to plugins pr-type/bug-fix This PR fixes a bug priority/high This issue is very important severity/p0 This bug blocks key user journey and function labels Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/plugins This issue or PR relates to plugins pr-type/bug-fix This PR fixes a bug priority/high This issue is very important severity/p0 This bug blocks key user journey and function size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][Linker] clearHistoryData deletes pull_request_issues from other projects when repos are shared

1 participant