Local repository: Find/Save/Install fail with TryConvertFromHashtableForPsd1 NullReferenceException when RequiredModules is a single hashtable (e.g. dbatools)
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 68/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- C#
- Sterne
- 578
- Forks
- 114
- Ø Merge
- 16 Std. 26 Min.
- Gemergte PRs (30 T.)
- 3
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus PowerShell/PSResourceGet
-
Create parent directories only after the containment check in InstallHelper.TryExtractToDirectoryOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
PowerShell/PSResourceGet#2056 ·
-
feature_request
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
PowerShell/PSResourceGet#2013 · 3 Kommentare ·
-
Set-PSResourcerepository fails on new installation of PS-Core 7.6.7Evtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. OffenNeeds-Triage
Schwierigkeit 3/5 Ein halber Tag Anfängerfreundlichkeit 52/100
PowerShell/PSResourceGet#2066 · 1 Kommentar ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
PowerShell/PSResourceGet#2063 · 5 Kommentare ·
-
PSResourceGet 1.3.0-preview2 error when installing AZ ModuleEvtl. vergeben @alerickson hat das vor 3 Tagen übernommen. OffenNeeds-Triage
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
PowerShell/PSResourceGet#2061 · 1 Kommentar · 1 zugewiesene Person ·
Alle Issues in PowerShell/PSResourceGet
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
Devolutions/UniGetUI#5541 ·
Maintainer antworten meist innerhalb von 1 Tag
-
agentic-workflows Needs: Triage :mag:
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
[誤判定]Offenlinux アプリ: ブラウザー 再現済み 要トリアージ 誤判定
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
yksr-melt/Meltype#853 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
S: Untriaged
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Trauma-Station/Trauma-Station#5073 ·
Maintainer antworten meist innerhalb von 1 Tag