From 516f1a019f26faad4c6c28a685352901650c4311 Mon Sep 17 00:00:00 2001 From: Cory Knox Date: Wed, 6 Nov 2024 09:20:45 -0800 Subject: [PATCH] (#3503, #3513) Add null check for CommandName The CommandName is null when the list method is called during alternate source commands. --- src/chocolatey/infrastructure.app/services/NugetService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index e0a72613d..7e4251846 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -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) ) &&