Local repository: Find/Save/Install fail with TryConvertFromHashtableForPsd1 NullReferenceException when RequiredModules is a single hashtable (e.g. dbatools)
還沒有人認領這個 Issue。
評估
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
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
- 主要語言
- C#
- 星號
- 578
- 分支
- 114
- 平均合併
- 1 天 16 小時
- 30 天內合併 PR
- 3
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
PowerShell/PSResourceGet 的其他 Issue
-
Create parent directories only after the containment check in InstallHelper.TryExtractToDirectory未關閉
難度 2/5 1-3 小時 新手友好度 78/100
PowerShell/PSResourceGet#2056 ·
-
feature_request
難度 2/5 1-3 小時 新手友好度 68/100
PowerShell/PSResourceGet#2013 · 3 則留言 ·
-
feature_request Needs-Triage
難度 5/5 一週以上 新手友好度 35/100
PowerShell/PSResourceGet#2068 ·
-
Needs-Triage
難度 3/5 半天 新手友好度 52/100
PowerShell/PSResourceGet#2066 · 1 則留言 ·
-
難度 4/5 3-5 天 新手友好度 48/100
PowerShell/PSResourceGet#2063 · 5 則留言 ·
查看 PowerShell/PSResourceGet 的全部 Issue
相似的 Issue
-
enhancement
難度 2/5 1-3 小時 新手友好度 65/100
KnifeLemon/Filee#294 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 66/100
gavin-wolfe/wolfden#104 ·
維護者通常 1 天內回覆
-
[BUG] Still libmicrohttpd dependency is not removed properly from External-Dependency-Info.txt file可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉type/bug
難度 1/5 1 小時以內 新手友好度 72/100
維護者通常 1 天內回覆
-
area:framework
難度 1/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
validate_environment_path strips executable extensions from directory names, not only from the end of the path可能已有人在做 @auraseb 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 86/100
Unity-Technologies/ml-agents#6332 ·