Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NullReferenceException for dotnet tool update -g --all #43157

Merged
merged 5 commits into from
Sep 30, 2024

Conversation

DL444
Copy link
Contributor

@DL444 DL444 commented Sep 1, 2024

Fixes #42598 and fixes #43158.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Workloads untriaged Request triage from a team member labels Sep 1, 2024
@DL444
Copy link
Contributor Author

DL444 commented Sep 1, 2024

/azp run dotnet-sdk-public-ci

Copy link

Commenter does not have sufficient privileges for PR 43157 in repo dotnet/sdk

@DL444

This comment has been minimized.

Copy link
Member

@nagilson nagilson left a comment

Choose a reason for hiding this comment

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

Thank you for this change and contributing to .NET Tools. Your fix looks great to me and I appreciate the thorough writeup. I agree with how you handled the --tool-path scenario though I am admittedly unfamiliar with this part of the codebase as well.

It would be ideal to have a test to demonstrate the behavior is fixed and prevent regression, but not a merge blocker.

Note since this is in main only, it would only go into .NET 10 most likely. I think we want this in .NET 9 too.

@nagilson
Copy link
Member

/backport to release/9.0.1xx-rc2

Copy link
Contributor

Started backporting to release/9.0.1xx-rc2: https:/dotnet/sdk/actions/runs/10910656220

@nagilson
Copy link
Member

@dsplaisted Are you ok to merge this without a test and do you agree this is a good candidate for rc2?

@nagilson
Copy link
Member

/backport to release/8.0.4xx

@nagilson
Copy link
Member

@DL444 We would be happy to merge this and we are going to merge this fix in 8.0.400 and 9.0.100 rc2 now but it wont be in any of the future releases until we merge it into 9.0.1xx. Would you mind retargetting this to the release/9.0.1xx branch and adding a test? If you can do that, we'd be happy to merge it.

@nagilson
Copy link
Member

/backport to release/8.0.4xx

Copy link
Contributor

Started backporting to release/8.0.4xx: https:/dotnet/sdk/actions/runs/10910761384

Copy link
Contributor

@nagilson backporting to release/8.0.4xx failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Fix null reference exception for full global tools update.
Applying: Fix empty ID in message when global package is up to date.
Using index info to reconstruct a base tree...
M	src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallGlobalOrToolPathCommand.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallGlobalOrToolPathCommand.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallGlobalOrToolPathCommand.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0002 Fix empty ID in message when global package is up to date.
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

Copy link
Contributor

@nagilson an error occurred while backporting to release/8.0.4xx, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

@nagilson
Copy link
Member

nagilson commented Sep 17, 2024

@DL444 We would be happy to merge this and we are going to merge this fix in 8.0.400 and 9.0.100 rc2 now but it wont be in any of the future releases until we merge it into 9.0.1xx. Would you mind retargetting this to the release/9.0.1xx branch and adding a test? If you can do that, we'd be happy to merge it.

Bumping this to the top so it's more visible.

For 8.0.4xx, the code is significantly different so some time will have to be spent to backport it. We would also appreciate it if you could backport this fix so it can go into .NET 8. I will try to take a look at this if it's not done when I have finished some other work items.

@DL444
Copy link
Contributor Author

DL444 commented Sep 17, 2024

Would you mind retargetting this to the release/9.0.1xx branch

Sure, I'll see what it takes soon, and I assume it should be relatively straightforward. Backporting to .NET 8 probably can't be done automatically, but it shouldn't be too complicated since I originally developed this fix for .NET 8 and then ported to main.

By the way, just to be sure: by "retargeting this to release/9.0.1xx" you mean creating a separate PR targeting that branch and keeping this one as-is, right? Or should I just change the target branch of this PR and then merging into main will be handled for me automatically?

and adding a test

Tests are currently not added because of testability problems I see, and I may need some guidance to proceed. To reproduce the problem, tools have to be actually installed into the runner's global store. Any mocking using an alternative store location will mask the problematic code path, which is why the issue wasn't caught by existing tests. I'm not sure testing this way is acceptable, or if there are better ways to approach this.

@nagilson
Copy link
Member

nagilson commented Sep 17, 2024

Thank you for your help. You can keep this PR as is and change the merge target. Any changes in 9.0.1xx will automatically get merged into the main branch as well. We appreciate your contribution in improving .NET. 😊 Sorry it took a bit for me to get to the review.

I will go through the process to get it approved in RC 2 as well as 8.0.400 once the PR is created.

To add tests, I see what you mean now and how the original test did not cover this case. I will have to look and see if there is any possible way for us to test this well, so dont worry about that. Off the top of my head, you're right in that the existing test code don't really support testing this scenario.

@DL444 DL444 changed the base branch from main to release/9.0.1xx September 18, 2024 01:52
@DL444 DL444 requested review from a team, tmat and arkalyanms as code owners September 18, 2024 01:52
@MichaelSimons MichaelSimons removed request for a team September 18, 2024 13:53
@DL444
Copy link
Contributor Author

DL444 commented Sep 18, 2024

Related backport PR:
#43516 .NET 9 RC 2
#43550 .NET 8

@nagilson
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@nagilson
Copy link
Member

The failures are an unrelated repo issue. Will check in on this again later to rerun

@nagilson nagilson removed request for a team September 18, 2024 18:46
@baronfel
Copy link
Member

/azp run dotnet-sdk-public-ci

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@baronfel
Copy link
Member

The 8.0.4xx backport merged and was servicing approved - @nagilson was this one approved at the same time?

@DL444
Copy link
Contributor Author

DL444 commented Sep 30, 2024

The changes were previously approved but merging was blocked by irrelevant CI problems.

@baronfel
Copy link
Member

@DL444 they are PR code approved, but we also have a .NET process requirement to get changes approved by our management because of how close we are to release.

@DL444
Copy link
Contributor Author

DL444 commented Sep 30, 2024

Oh, I misunderstood that. Approval status for this PR wasn't communicated before so I'm unable to tell.

@nagilson nagilson merged commit 1dcae19 into dotnet:release/9.0.1xx Sep 30, 2024
31 checks passed
@nagilson
Copy link
Member

This was approved, thank you for checking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Workloads Servicing-approved untriaged Request triage from a team member
Projects
None yet
3 participants