Fix key collision when multiple PRs share the same merge commit SHA#114
Merged
Malcolmnixon merged 2 commits intomainfrom Mar 23, 2026
Merged
Fix key collision when multiple PRs share the same merge commit SHA#114Malcolmnixon merged 2 commits intomainfrom
Malcolmnixon merged 2 commits intomainfrom
Conversation
Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> Agent-Logs-Url: https://github.com/demaconsulting/BuildMark/sessions/eb6517f4-1c6a-444e-90d8-8fc5932629c9
Copilot
AI
changed the title
[WIP] Fix key collision error in BuildMark
Fix key collision when multiple PRs share the same merge commit SHA
Mar 23, 2026
Malcolmnixon
approved these changes
Mar 23, 2026
There was a problem hiding this comment.
Pull request overview
Fixes a crash in GitHubRepoConnector lookup construction when multiple pull requests share the same merge commit SHA, which can occur in certain GitHub workflows.
Changes:
- Deduplicates the commit-SHA-to-PR mapping in
BuildLookupDatato avoidToDictionary()duplicate-key exceptions. - Adds a regression test covering duplicate merge commit SHA behavior using the reported SHA.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/DemaConsulting.BuildMark/RepoConnectors/GitHubRepoConnector.cs |
Updates BuildLookupData to safely handle duplicate commit SHA keys when building the PR lookup map. |
test/DemaConsulting.BuildMark.Tests/GitHubRepoConnectorTests.cs |
Adds a regression test ensuring GetBuildInformationAsync does not throw when duplicate merge commit SHAs are present. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Pull Request
Description
BuildLookupDatacrashed withArgumentException: An item with the same key has already been addedwhen two or more pull requests shared the same merge commit SHA — a condition possible with certain GitHub repo configurations (e.g., squash/re-merge workflows).Root cause:
.ToDictionary()oncommitHashToPrthrows on duplicate keys.Fix: Use
.GroupBy().ToDictionary()to deduplicate, keeping the first PR in collection order per SHA:A regression test was added using the exact SHA from the bug report (
c85989fd08aee2b768557f6b90011ec325b3bdea).Type of Change
Related Issues
Pre-Submission Checklist
Before submitting this pull request, ensure you have completed the following:
Build and Test
dotnet build --configuration Releasedotnet test --configuration Releasedotnet run --project src/DemaConsulting.BuildMark --configuration Release --framework net10.0--no-build -- --validateCode Quality
dotnet format --verify-no-changesQuality Checks
Please run the following checks before submitting:
cspell "**/*.{md,cs}"markdownlint "**/*.md"yamllint '**/*.{yml,yaml}'Testing
Documentation
Additional Notes
All 175 tests pass. CodeQL reports 0 alerts.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/graphql/usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/BuildMark/BuildMark/test/DemaConsulting.BuildMark.Tests/bin/Release/net10.0/DemaConsulting.BuildMark.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/BuildMark/BuildMark/test/DemaConsulting.BuildMark.Tests/bin/Release/net10.0/DemaConsulting.BuildMark.Tests.deps.json /home/REDACTED/work/BuildMark/BuildMark/test/DemaConsulting.BuildMark.Tests/bin/Release/net10.0/testhost.dll --port 43301 --endpoint 127.0.0.1:043301 --role client --parentprocessid 4277 --telemetryoptedin false(http block)/usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/BuildMark/BuildMark/test/DemaConsulting.BuildMark.Tests/bin/Release/net9.0/DemaConsulting.BuildMark.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/BuildMark/BuildMark/test/DemaConsulting.BuildMark.Tests/bin/Release/net9.0/DemaConsulting.BuildMark.Tests.deps.json /home/REDACTED/work/BuildMark/BuildMark/test/DemaConsulting.BuildMark.Tests/bin/Release/net9.0/testhost.dll --port 33733 --endpoint 127.0.0.1:033733 --role client --parentprocessid 4275 --telemetryoptedin false(http block)/usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/BuildMark/BuildMark/test/DemaConsulting.BuildMark.Tests/bin/Release/net8.0/DemaConsulting.BuildMark.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/BuildMark/BuildMark/test/DemaConsulting.BuildMark.Tests/bin/Release/net8.0/DemaConsulting.BuildMark.Tests.deps.json /home/REDACTED/work/BuildMark/BuildMark/test/DemaConsulting.BuildMark.Tests/bin/Release/net8.0/testhost.dll --port 44369 --endpoint 127.0.0.1:044369 --role client --parentprocessid 4276 --telemetryoptedin false(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.