Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Get-WinGetManifest logic is broken around how it performs path detection

オープン
#180 コメント 1 件 リアクション 0 件 担当者 1 名 GitHub で見る

@RDMacLachlan がすでに取り組んでいます。

2022年10月5日 から。

評価

この issue はまだ評価されていません。

説明

Issue-Bug
Brief description of your issue

When processing files in a directory, $PathChildItemsJSON and/or $PathChildItemsYAML may be null. This is not accounted for in the subsequent if/else statements that perform validation. If one or the other is null, this will fail internally because of null references. Strict mode is not enabled for these scripts, so the failure cause is not obvious to the caller:

VERBOSE: Path pointed to a directory, found 0 JSON files, and 0 YAML files.
Get-WinGetManifest: D:\b\winget-cli-restsource-ameltzer\bin\Library\Add-WinGetManifest.ps1:109:32
Line |
 109 |          $ApplicationManifest = Get-WinGetManifest -Path $Path
     |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Directory does not contain any combination of JSON and YAML files.

VERBOSE: Returning (0) manifests based on search.
Exception: D:\b\winget-cli-restsource-ameltzer\bin\Library\Add-WinGetManifest.ps1:111:13
Line |
 111 |              throw "Failed to retrieve a proper manifest. Verify and t …
     |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Failed to retrieve a proper manifest. Verify and try again.

This gives the appearance of there being no YAML or JSON files, but there's actually 4 yaml files in my directory. Running again with Set-StrictMode -Version Latest shows detailed failure information:

VERBOSE: Retrieving a copy of the app Manifest file for submission to WinGet source.
PropertyNotFoundException: D:\b\winget-cli-restsource-ameltzer\bin\Library\Get-WinGetManifest.ps1:162:77      
Line |
 162 |  … ath pointed to a directory, found $($PathChildItemsJSON.count) JSON f …
     |                                        ~~~~~~~~~~~~~~~~~~~~~~~~~
     | The property 'count' cannot be found on this object. Verify that the property exists.

VERBOSE: Path pointed to a directory, found  JSON files, and 4 YAML files.
PropertyNotFoundException: D:\b\winget-cli-restsource-ameltzer\bin\Library\Get-WinGetManifest.ps1:166:24      
Line |
 166 |  …          if($PathChildItemsJSON.count -eq 0 -and $PathChildItemsYAML. …
     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The property 'count' cannot be found on this object. Verify that the property exists.

InvalidOperation: D:\b\winget-cli-restsource-ameltzer\bin\Library\Get-WinGetManifest.ps1:264:25
Line |
 264 |                  switch ($ManifestFileType) {
     |                          ~~~~~~~~~~~~~~~~~
     | The variable '$ManifestFileType' cannot be retrieved because it has not been set.

This can be fixed by doing this:

                    $PathChildItemsJSON = Get-ChildItem -Path $Path -Filter "*.json" -ErrorAction SilentlyContinue
                    if (!$PathChildItemsJSON) {
                        $PathChildItemsJSON = @()
                    }
                    $PathChildItemsYAML = Get-ChildItem -Path $Path -Filter "*.yaml" -ErrorAction SilentlyContinue
                    if (!$PathChildItemsYAML) {
                        $PathChildItemsYAML = @()
                    }

Unfortunately, while fixing this works around the null reference issues, it then runs into #179 :(

VERBOSE: Retrieving a copy of the app Manifest file for submission to WinGet source.
VERBOSE: Path pointed to a directory, found 0 JSON files, and 4 YAML files.
VERBOSE: Single YAML has been found in the specified directory.
Get-WinGetManifest: D:\b\winget-cli-restsource-ameltzer\bin\Library\Add-WinGetManifest.ps1:109:32
Line |
 109 |          $ApplicationManifest = Get-WinGetManifest -Path $Path
     |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Unable to process YAML files. Re-import the module to reload the required dependencies.

VERBOSE: Returning (0) manifests based on search.
Exception: D:\b\winget-cli-restsource-ameltzer\bin\Library\Add-WinGetManifest.ps1:111:13
Line |
 111 |              throw "Failed to retrieve a proper manifest. Verify and t …
     |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Failed to retrieve a proper manifest. Verify and try again.
Steps to reproduce

Run Add-WinGetManifest and point to a path with .yaml documents.

主要言語
C#
スター
317
フォーク
79
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/winget-cli-restsource のほかの issue

microsoft/winget-cli-restsource の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。