Skip to content

Commit

Permalink
(chocolatey#3503, chocolatey#3513) Add null check for CommandName
Browse files Browse the repository at this point in the history
The CommandName is null when the list method is called during alternate
source commands.
  • Loading branch information
corbob committed Nov 6, 2024
1 parent 3b7baf7 commit 516f1a0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/chocolatey/infrastructure.app/services/NugetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ it is possible that incomplete package lists are returned from a command
// The main scenario where we desire the decrypted arguments during a list sequence is to display them when verbose output is selected.
// This is done by default on the `info` command, and by request on the `list` command. As such, we are going to validate it's that scenario
// to avoid needlessly decrypting the arguments file.
var shouldDecryptArguments = (
var shouldDecryptArguments = !string.IsNullOrWhiteSpace(config.CommandName) &&
(
config.CommandName.Equals("info", StringComparison.OrdinalIgnoreCase) ||
config.CommandName.Equals("list", StringComparison.OrdinalIgnoreCase)
) &&
Expand Down

0 comments on commit 516f1a0

Please sign in to comment.