Local repository: Find/Save/Install fail with TryConvertFromHashtableForPsd1 NullReferenceException when RequiredModules is a single hashtable (e.g. dbatools)
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 68/100
Direção de pesquisa
Reproduce the failure with the provided Repro.Single and Repro.Array manifest script, then trace the TryConvertFromHashtableForPsd1 path named in the error. Add a regression test for a single-hashtable RequiredModules value and verify Find-PSResource, Save-PSResource, and Install-PSResource handle it like the array form.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
Steps to reproduce
I think the following is correct, Claude Code suggested I raise it!
Steps to reproduce
RequiredModules = @{ ModuleName = 'X'; ModuleVersion = '1.0.0' } (a single hashtable, not wrapped in @()) is a valid module manifest. Import-Module, Test-ModuleManifest and the PowerShell Gallery all accept it, and dbatools uses it (dbatools 2.9.0 requires dbatools.library this way). But PSResourceGet cannot find, save or install such a package from a local (file-share) repository, even with -SkipDependencyCheck. The same manifest with RequiredModules = @(@{ ... }) works.
$Work = Join-Path ([IO.Path]::GetTempPath()) ([guid]::NewGuid())
New-Item -ItemType Directory -Path "$Work\pkg", "$Work\out" -Force | Out-Null
foreach ($Case in @{ Name = 'Repro.Single'; Requires = "@{ ModuleName = 'Repro.Lib'; ModuleVersion = '1.0.0' }" },
@{ Name = 'Repro.Array'; Requires = "@(@{ ModuleName = 'Repro.Lib'; ModuleVersion = '1.0.0' })" }) {
$Src = New-Item -ItemType Directory -Path "$Work\src\$($Case.Name)" -Force
Set-Content "$Src\$($Case.Name).psm1" ''
Set-Content "$Src\$($Case.Name).psd1" "@{ RootModule = '$($Case.Name).psm1'; ModuleVersion = '1.0.0'; GUID = '$([guid]::NewGuid())'; Author = 'T'; Description = 'T'; RequiredModules = $($Case.Requires) }"
Compress-PSResource -Path $Src -DestinationPath "$Work\pkg" -SkipModuleManifestValidate
}
Register-PSResourceRepository -Name Repro -Uri "$Work\pkg" -Trusted
Save-PSResource -Name Repro.Array -Version 1.0.0 -Repository Repro -Path "$Work\out" -TrustRepository -SkipDependencyCheck # works
Save-PSResource -Name Repro.Single -Version 1.0.0 -Repository Repro -Path "$Work\out" -TrustRepository -SkipDependencyCheck # fails
Unregister-PSResourceRepository -Name Repro
The same happens with the real package: Save-PSResource -Name dbatools -AsNupkg from PSGallery, register that folder as a repository, then Find-PSResource -Name dbatools -Repository <it>.
Find-PSResource and Install-PSResource fail the same way. A package that depends on dbatools then fails with Dependency package with name 'dbatools' could not be found in repository.
Expected behavior
`Repro.Single` is found and saved, as `Repro.Array` is, with `Repro.Lib` as its dependency.
Actual behavior
Save-PSResource: TryConvertFromHashtableForPsd1: Could not find expected information from module manifest file hashtable with error: Object reference not set to an instance of an object.
Error details
Environment data
PowerShell 7.x, Windows 11 Enterprise 10.0.26200
Microsoft.PowerShell.PSResourceGet 1.2.0
Visuals
No response
- Linguagem predominante
- C#
- Estrelas
- 578
- Forks
- 114
- Merge médio
- 16h 26min
- PRs com merge (30d)
- 3
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de PowerShell/PSResourceGet
-
Create parent directories only after the containment check in InstallHelper.TryExtractToDirectoryAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
PowerShell/PSResourceGet#2056 ·
-
feature_request
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
PowerShell/PSResourceGet#2013 · 3 comentários ·
-
Set-PSResourcerepository fails on new installation of PS-Core 7.6.7Talvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. AbertaNeeds-Triage
Dificuldade 3/5 Meio dia Facilidade para iniciantes 52/100
PowerShell/PSResourceGet#2066 · 1 comentário ·
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
PowerShell/PSResourceGet#2063 · 5 comentários ·
-
PSResourceGet 1.3.0-preview2 error when installing AZ ModuleTalvez já em andamento @alerickson assumiu há 3 dias. AbertaNeeds-Triage
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 55/100
PowerShell/PSResourceGet#2061 · 1 comentário · 1 responsável ·
Todas as issues de PowerShell/PSResourceGet
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia
-
dette technique priorité: basse zone: service
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
damiensabau/nexus-lobby#25 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
sebastienros/jint#4282 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 76/100
pyrevitlabs/pyRevit#3792 ·
Mantenedores costumam responder em até 1 dia