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

list/search/info - searching with --exact or info results in Object reference not set to an instance of an object #1837

Closed
jborean93 opened this issue May 31, 2019 · 6 comments

Comments

@jborean93
Copy link

jborean93 commented May 31, 2019

What You Are Seeing?

Using choco.exe list --exact <missing package name> results in an error with an rc of 1

C:\Windows\system32>choco list --exact some_weird_package
Chocolatey v0.10.14
Object reference not set to an instance of an object.

C:\Windows\system32>echo %ERRORLEVEL%
1

This affects the win_chocolatey module in Ansible as we run choco list --exact --local-only <package name> to test whether a package is installed or not. Unfortunately I cannot see a way around this and so we will start being inundated with GitHub bugs until a new Chocolatey release with this fix is in.

What is Expected?

C:\Windows\system32>choco list --exact some_weird_package
Chocolatey v0.10.11
0 packages found.

C:\Windows\system32>echo %ERRORLEVEL%
0  # or 2 depending on the feature flag

How Did You Get This To Happen? (Steps to Reproduce)

Make sure you are on 0.10.14 and run the command above.

Output Log

Full Log Output

C:\Windows\system32>choco list --exact some_weird_package --debug --verbose
Chocolatey v0.10.14
Chocolatey is running on Windows v 10.0.17763.0
Attempting to delete file "C:/ProgramData/chocolatey/choco.exe.old".
Attempting to delete file "C:\ProgramData\chocolatey\choco.exe.old".
Command line: "C:\ProgramData\chocolatey\choco.exe" list --exact some_weird_package --debug --verbose
Received arguments: list --exact some_weird_package --debug --verbose
RemovePendingPackagesTask is now ready and waiting for PreRunMessage.
Sending message 'PreRunMessage' out if there are subscribers...
[Pending] Removing all pending packages that should not be considered installed...
Performing validation checks.
Global Configuration Validation Checks:
 - Package Exit Code / Exit On Reboot = Checked
System State Validation Checks:
 Reboot Requirement Checks:
 - Pending Computer Rename = Checked
 - Pending Component Based Servicing = Checked
 - Pending Windows Auto Update = Checked
 - Pending File Rename Operations = Checked
 - Pending Windows Package Installer = Checked
 - Pending Windows Package Installer SysWow64 = Checked
The source 'https://chocolatey.org/api/v2/' evaluated to a 'normal' source type

NOTE: Hiding sensitive configuration data! Please double and triple
 check to be sure no sensitive data is shown, especially if copying
 output to a gist for review.
Configuration: CommandName='list'|
CacheLocation='C:\Users\vagrant\AppData\Local\Temp\chocolatey'|
ContainsLegacyPackageInstalls='True'|
CommandExecutionTimeoutSeconds='2700'|WebRequestTimeoutSeconds='30'|
Sources='https://chocolatey.org/api/v2/'|SourceType='normal'|
Debug='True'|Verbose='True'|Trace='False'|Force='False'|Noop='False'|
HelpRequested='False'|UnsuccessfulParsing='False'|RegularOutput='True'|
QuietOutput='False'|PromptForConfirmation='True'|AcceptLicense='False'|
AllowUnofficialBuild='False'|Input='some_weird_package'|
AllVersions='False'|SkipPackageInstallProvider='False'|
Prerelease='False'|ForceX86='False'|OverrideArguments='False'|
NotSilent='False'|ApplyPackageParametersToDependencies='False'|
ApplyInstallArgumentsToDependencies='False'|IgnoreDependencies='False'|
AllowMultipleVersions='False'|AllowDowngrade='False'|
ForceDependencies='False'|Information.PlatformType='Windows'|
Information.PlatformVersion='10.0.17763.0'|
Information.PlatformName='Windows Server 2016'|
Information.ChocolateyVersion='0.10.14.0'|
Information.ChocolateyProductVersion='0.10.14'|
Information.FullName='choco, Version=0.10.14.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb'|

Information.Is64BitOperatingSystem='True'|
Information.Is64BitProcess='True'|Information.IsInteractive='True'|
Information.UserName='vagrant'|
Information.UserDomainName='WIN-C8BPPV878V8'|
Information.IsUserAdministrator='True'|
Information.IsUserSystemAccount='False'|
Information.IsUserRemoteDesktop='False'|
Information.IsUserRemote='True'|
Information.IsProcessElevated='True'|
Information.IsLicensedVersion='False'|Information.LicenseType='Foss'|
Information.CurrentDirectory='C:\Windows\system32'|
Features.AutoUninstaller='True'|Features.ChecksumFiles='True'|
Features.AllowEmptyChecksums='False'|
Features.AllowEmptyChecksumsSecure='True'|
Features.FailOnAutoUninstaller='False'|
Features.FailOnStandardError='False'|Features.UsePowerShellHost='True'|
Features.LogEnvironmentValues='False'|Features.LogWithoutColor='False'|
Features.VirusCheck='False'|
Features.FailOnInvalidOrMissingLicense='False'|
Features.IgnoreInvalidOptionsSwitches='True'|
Features.UsePackageExitCodes='True'|
Features.UseEnhancedExitCodes='False'|
Features.UseFipsCompliantChecksums='False'|
Features.ShowNonElevatedWarnings='True'|
Features.ShowDownloadProgress='True'|
Features.StopOnFirstPackageFailure='False'|
Features.UseRememberedArgumentsForUpgrades='False'|
Features.IgnoreUnfoundPackagesOnUpgradeOutdated='False'|
Features.SkipPackageUpgradesWhenNotInstalled='False'|
Features.RemovePackageInformationOnUninstall='False'|
Features.ExitOnRebootDetected='False'|
Features.LogValidationResultsOnWarnings='True'|
Features.UsePackageRepositoryOptimizations='True'|
Features.ScriptsCheckLastExitCode='False'|
ListCommand.LocalOnly='False'|
ListCommand.IdOnly='False'|ListCommand.IncludeRegistryPrograms='False'|
ListCommand.PageSize='25'|ListCommand.Exact='True'|
ListCommand.ByIdOnly='False'|ListCommand.ByTagOnly='False'|
ListCommand.IdStartsWith='False'|ListCommand.OrderByPopularity='False'|
ListCommand.ApprovedOnly='False'|
ListCommand.DownloadCacheAvailable='False'|
ListCommand.NotBroken='False'|
ListCommand.IncludeVersionOverrides='False'|
UpgradeCommand.FailOnUnfound='False'|
UpgradeCommand.FailOnNotInstalled='False'|
UpgradeCommand.NotifyOnlyAvailableUpgrades='False'|
UpgradeCommand.ExcludePrerelease='False'|
NewCommand.AutomaticPackage='False'|
NewCommand.UseOriginalTemplate='False'|SourceCommand.Command='unknown'|
SourceCommand.Priority='0'|SourceCommand.BypassProxy='False'|
SourceCommand.AllowSelfService='False'|
SourceCommand.VisibleToAdminsOnly='False'|
FeatureCommand.Command='unknown'|ConfigCommand.Command='unknown'|
ApiKeyCommand.Remove='False'|PinCommand.Command='unknown'|
OutdatedCommand.IgnorePinned='False'|Proxy.BypassOnLocal='True'|
_ Chocolatey:ChocolateyListCommand - Normal Run Mode _
Searching for package information
Running list with the following filter = 'some_weird_package'
--- Start of List ---
Using 'https://chocolatey.org/api/v2/'.
- Supports prereleases? 'True'.
- Is ServiceBased? 'True'.
Sending message 'PostRunMessage' out if there are subscribers...
Chocolatey had an error occur:
System.NullReferenceException: Object reference not set to an instance of an object.
   at chocolatey.infrastructure.app.services.NugetService.<>c__DisplayClass13.<list_run>b__4()
   at chocolatey.infrastructure.logging.Log4NetLog.Info(Func`1 message)
   at chocolatey.infrastructure.app.services.NugetService.<list_run>d__15.MoveNext()
   at chocolatey.infrastructure.app.services.ChocolateyPackageService.<list_run>d__17.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at chocolatey.infrastructure.app.commands.ChocolateyListCommand.run(ChocolateyConfiguration configuration)
   at chocolatey.infrastructure.app.runners.GenericRunner.run(ChocolateyConfiguration config, Container container, Boolean isConsole, Action`1 parseArgs)
   at chocolatey.infrastructure.app.runners.ConsoleApplication.run(String[] args, ChocolateyConfiguration config, Container container)
   at chocolatey.console.Program.Main(String[] args)
Exiting with 1

@PinkieSwirl
Copy link

This also happens for choco info, which produces the following ouput:

> choco info
Chocolatey v0.10.14
Object reference not set to an instance of an object.

gep13 added a commit to gep13/choco that referenced this issue May 31, 2019
find_package will either return the package that was found, or null.
The case for null being returned needs to be handled, so that upstream
callers are not affected.
@gep13 gep13 self-assigned this May 31, 2019
ferventcoder added a commit that referenced this issue May 31, 2019
 (GH-1837) Handle potential for null package
@gep13 gep13 added this to the 0.10.15 milestone May 31, 2019
gep13 added a commit that referenced this issue May 31, 2019
* stable:
  (GH-1837) Handle potential for null package
  (maint) Correct whitespace
  (version) 0.10.15-beta
@cwegener
Copy link

Thanks for the quick response on this issue. (The regression caused me a bit of drama this morning and @jborean93 was of great help in getting this addresses quickly)

How can a pre-release build of chocolatey be tested easily?

I downloaded the build artifact for 0f86f78 from AppVeyor and installed the nupkg with choco intall, but I'm not sure if that's the right way to do it?

choco.exe is now barking about a non-official build, which makes sense I guess.

Will there be a pre-release added to the nupkg feed for easier testing?

@gep13
Copy link
Member

gep13 commented May 31, 2019

@cwegener I have actually just released a beta version of chocolatey which you can grab from here:

https://chocolatey.org/packages/chocolatey/0.10.15-beta-20190531

It is still working it's way through the moderation process, but you can grab it directly.

@gep13 gep13 closed this as completed May 31, 2019
@ferventcoder ferventcoder changed the title Chocolatey 0.10.14 list Object reference not set to an instance of an object list/search/info - searching with --exact or info results in Object reference not set to an instance of an object Jun 3, 2019
@ferventcoder
Copy link
Member

Chocolatey v0.10.15 is being pushed out in the next hour.

@ferventcoder
Copy link
Member

Thanks for catching this. I've added an additional scenario to the specs to find this to prevent any future regressions.

ferventcoder added a commit that referenced this issue Jun 3, 2019
Added tests to ensure that no results does not result in an error when
searching with info or by exact name of package.
ferventcoder added a commit that referenced this issue Jun 3, 2019
The specs produce a Scenarios file, ensure that is updated with the
latest results.
ferventcoder added a commit that referenced this issue Jun 3, 2019
* stable:
  (GH-1837) update behavior scenarios
  (version) 0.10.15
  (doc) update release notes for 0.10.15
  (maint) formatting
  (GH-1837) Specs: ensure zero results on info/exact
  (spec) adding additional checks
@Yuri-GG
Copy link

Yuri-GG commented Jun 4, 2019

Thank you guys for fix 'Object reference not set to an instance of an object'!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants