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

Test-Json returns wrong error when SchemaFile is not found

オープン 初心者向け
#27,973 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
74/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
csharp, powershell
領域
cli

調査の方向性

TestJsonCommand.BeginProcessing と JsonSchema.FromFile の呼び出しから始め、次に fooSchema.json が存在しない状態で、提供されている Test-Json の再現を実行します。完了条件は、存在しないスキーマによって、現在のファイルオープン時の文言ではなく、報告されたパスに対して期待される「Cannot find JSON schema file」エラーが生成されることです。

索引モデルが issue の本文から書いたものです。

説明

Needs-Triage
Prerequisites
Steps to reproduce

Use a valid json file test.json as shown in below example. Test its schema by passing an invalid schema file json.

> cat test.json
{
    "str": "somestring",
    "int": 2026
}

>Test-Json -Path .\test.json -SchemaFile .\fooSchema.json
Expected behavior
Test-Json: Cannot find JSON schema file: C:\Windows\Temp\fooSchema.json
Actual behavior
> Test-Json: Can not open JSON schema file: C:\Windows\Temp\fooSchema.json
Error details
Exception             : 
    Type           : System.Exception
    TargetSite     : 
        Name          : ThrowTerminatingError
        DeclaringType : [System.Management.Automation.MshCommandRuntime]
        MemberType    : Method
        Module        : System.Management.Automation.dll
    Message        : Can not open JSON schema file: C:\Windows\Temp\fooSchema.json
    InnerException : 
        Type       : System.IO.FileNotFoundException
        Message    : Could not find file 'C:\Windows\Temp\fooSchema.json'.
        FileName   : C:\Windows\Temp\fooSchema.json
        TargetSite : 
            Name          : CreateFile
            DeclaringType : [Microsoft.Win32.SafeHandles.SafeFileHandle]
            MemberType    : Method
            Module        : System.Private.CoreLib.dll
        Source     : System.Private.CoreLib
        HResult    : -2147024894
        StackTrace : 
   at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Int32 bufferSize)
   at System.IO.File.ReadAllText(String path, Encoding encoding)
   at Json.Schema.JsonSchema.FromFile(String fileName)
   at Microsoft.PowerShell.Commands.TestJsonCommand.BeginProcessing()
    Source         : System.Management.Automation
    HResult        : -2146233088
    StackTrace     : 
   at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
TargetObject          : C:\Windows\Temp\fooSchema.json
CategoryInfo          : OpenError: (C:\Windows\Temp\fooSchema.json:String) [Test-Json], Exception
FullyQualifiedErrorId : JsonSchemaFileOpenFailure,Microsoft.PowerShell.Commands.TestJsonCommand
InvocationInfo        : 
    MyCommand        : Test-Json
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 1
    Line             : Test-Json -Path .\test.json -SchemaFile .\fooSchema.json
    Statement        : Test-Json -Path .\test.json -SchemaFile .\fooSchema.json
    PositionMessage  : At line:1 char:1
                       + Test-Json -Path .\test.json -SchemaFile .\fooSchema.json
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Test-Json
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
Environment data

#Windows
Name                           Value
----                           -----
PSVersion                      7.6.5
PSEdition                      Core
GitCommitId                    7.6.5
OS                             Microsoft Windows 10.0.26200
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.4
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

#Linux
Name                           Value
----                           -----
PSVersion                      7.4.2
PSEdition                      Core
GitCommitId                    7.4.2
OS                             Ubuntu 20.04.6 LTS
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Visuals

No response

主要言語
C#
スター
55.5k
フォーク
8.5k
平均マージ
1日 17時間
マージ済み PR(30日)
97

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

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

はじめの一歩

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

PowerShell/PowerShell のほかの issue

PowerShell/PowerShell の issue をすべて見る

似ている issue

C# の issue をもっと見る

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

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