Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Local repository: Find/Save/Install fail with TryConvertFromHashtableForPsd1 NullReferenceException when RequiredModules is a single hashtable (e.g. dbatools)

Abierto
#2,059 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
powershell
Área
cli, tooling

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Needs-Triage
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

Lenguaje dominante
C#
Estrellas
577
Forks
114
Merge medio
23 h 17 min
PR fusionados (30 d)
8

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PowerShell/PSResourceGet

Todos los issues de PowerShell/PSResourceGet

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.