Attempt a source update when search fails
Description of the new feature / enhancement
Although this is an edge case scenario, it may be good to consider.
Assume the user has the default source 'winget' configured.
If a user runs the command winget source update, all available sources will be updated.
The user can then run winget list .NET to see all the .NET packages installed on their machine.
This is all normal and as expected.
If the user manually removes the Winget source package through the command Get-AppxPackage 'Microsoft.Winget.Source' | Remove-AppxPackage, the data for the winget source will be removed. This is not something which a typical user would do, but a power user may do. The user can then attempt to run winget list .NET to see all the .NET packages installed on their machine. Based on the user's configuration, one of two things may occur.
- If the user has multiple sources configured they will receive the warning:
Failed when searching source; results will not be included: winget
- If the only configured source is the default
wingetsource they will receive the error:
Failed when opening source(s); try the 'source reset' command if the problem persists.
An unexpected error occurred while executing the command:
0x8a15000f : Data required by the source is missing
However, in both cases, a source reset is not required. If the user waits until the source auto-update interval expires, the source will be updated and the search will succeed. Or, if the user runs winget source update, the source will be updated and the search will succeed.
Proposed technical implementation details
Given that the client already can detect these source errors, it would provide a smoother user experience if the client attempted to update the source and retry the search if such an error is encountered.