PowerShell / PowerShell/PSResourceGet
Update-PSResource Az failure
Open
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 576
- Forks
- 114
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 7
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest version
- Search the existing issues.
Steps to reproduce
I am unable to update the Az module.
Expected behavior
Az module would be updated.
Actual behavior
PS C:\> Update-PSResource Az -Repository PSGallery
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its Trusted value by running the Set-PSResourceRepository cmdlet. Are
you sure you want to install the PSResource from 'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A
Update-PSResource: 'An error occurred while sending the request.' Request sent: 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='Az.Advisor'&$orderby=NormalizedVersion%20desc&$inlinecount=allpages&$skip=0&$filter=Id%20eq%20'Az.Advisor'%20and%20NormalizedVersion%20ge%20'2.0.0'%20and%20NormalizedVersion%20le%20'2.0.9'' Inner exception: 'Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host..'
Update-PSResource: Object reference not set to an instance of an object.
Error details
PS C:\> Get-Error
Exception :
Type : System.NullReferenceException
TargetSite :
Name : InstallVersion
DeclaringType : Microsoft.PowerShell.PSResourceGet.Cmdlets.V2ServerAPICalls, Microsoft.PowerShell.PSResourceGet, Version=1.0.1.0, Culture=neutral,
PublicKeyToken=null
MemberType : Method
Module : Microsoft.PowerShell.PSResourceGet.dll
Message : Object reference not set to an instance of an object.
Source : Microsoft.PowerShell.PSResourceGet
HResult : -2147467261
StackTrace :
at Microsoft.PowerShell.PSResourceGet.Cmdlets.V2ServerAPICalls.InstallVersion(String packageName, String version, ErrorRecord& errRecord)
at Microsoft.PowerShell.PSResourceGet.Cmdlets.V2ServerAPICalls.InstallPackage(String packageName, String packageVersion, Boolean includePrerelease, ErrorRecord&
errRecord)
at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallHelper.BeginPackageInstall(VersionType searchVersionType, NuGetVersion specificVersion, VersionRange
versionRange, String pkgNameToInstall, PSRepositoryInfo repository, ServerApiCall currentServer, ResponseUtil currentResponseUtil, String tempInstallPath, Hashtable
packagesHash, ErrorRecord& errRecord)
at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallHelper.InstallPackages(String[] pkgNamesToInstall, PSRepositoryInfo repository, ServerApiCall currentServer,
ResponseUtil currentResponseUtil, ScopeType scope, Boolean skipDependencyCheck, FindHelper findHelper)
at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallHelper.ProcessRepositories(String[] repository, Boolean trustRepository, Boolean skipDependencyCheck,
ScopeType scope)
at Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallHelper.BeginInstallPackages(String[] names, VersionRange versionRange, NuGetVersion nugetVersion, VersionType
versionType, String versionString, Boolean prerelease, String[] repository, Boolean acceptLicense, Boolean quiet, Boolean reinstall, Boolean force, Boolean
trustRepository, Boolean noClobber, Boolean asNupkg, Boolean includeXml, Boolean skipDependencyCheck, Boolean authenticodeCheck, Boolean savePkg, List`1
pathsToInstallPkg, Nullable`1 scope, String tmpPath, HashSet`1 pkgsInstalled)
at Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
CategoryInfo : NotSpecified: (:) [Update-PSResource], NullReferenceException
FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource
InvocationInfo :
MyCommand : Update-PSResource
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 83
Line : Update-PSResource Az -Repository PSGallery
Statement : Update-PSResource Az -Repository PSGallery
PositionMessage : At line:1 char:1
+ Update-PSResource Az -Repository PSGallery
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : Update-PSResource
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
Environment data
PS C:\> $PSVersionTable
Name Value
---- -----
PSVersion 7.4.1
PSEdition Core
GitCommitId 7.4.1
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Version
Script 2.2.5 PowerShellGet Desk
Visuals
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Update-PSResource entry point and V2ServerAPICalls.InstallVersion named in the stack trace, then reproduce the Az update against PSGallery using the reported environment. Trace the transport failure and null reference, and consider the issue done when the command handles this failure without the reported Object reference error and its behavior is covered by a regression check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100