only try to create pr if update operations were performed#14463
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prevents the NuGet create_security_pr update handler from attempting to create a pull request when files were modified on disk but no update operations were actually performed (an edge case that can occur during analysis/MSBuild evaluation).
Changes:
- Gate PR creation on both (a) modified dependency files and (b) at least one update operation being performed.
- Add a regression test ensuring “errant” on-disk file edits with zero update operations do not trigger PR creation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/CreateSecurityUpdatePullRequestHandler.cs |
Adds an additional guard (updateOperationsPerformed.Count > 0) before creating a PR to avoid invalid PR generation when only file edits occurred. |
nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/CreateSecurityUpdatePullRequestHandlerTests.cs |
Adds a test that simulates a file being touched during analysis while CanUpdate=false, asserting no PR creation occurs. |
JamieMagee
approved these changes
Mar 16, 2026
35ded2d to
a66766b
Compare
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.
The NuGet
create_security_prhandler can get into a weird state if analysis updates a file on disk but no updates were possible.This is admittedly an edge case, but can happen if a project/props/targets injects targets that MSBuild evaluates that edits a tracked file but then no security update was possible. The result is a non-empty set of files with edits but an empty set of update operations which then causes errors when attempting to generate a PR. A PR is obviously incorrect here so the fix is to not only check the edited file count before creating a PR, but also to check the update operation count.