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

Test-Json in 7.6.7 writes no error for violations nested below the first level (e.g. array items)

オープン
#28,218 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

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

評価

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

調査の方向性

Start in the TestJsonCommand implementation, where ProcessRecord calls HandleValidationErrors on the root result and only its direct Details, and where _evaluationOptions switches to OutputFormat.Hierarchical. Reproduce with the two Test-Json calls in the issue, which should show /list/1 is missing from the errors. Done means nested and array-item violations write one error each on the release/v7.6 branch, ideally backported from the recursive ReportValidationErrors on master and covered by a test.

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

説明

Issue-Bug
Prerequisites
Steps to reproduce

This is a regression from 7.6.6 to 7.6.7. When a schema violation is nested deeper than one level (for example an array item), Test-Json still returns False, but it no longer writes an error that says what is wrong or where. Violations at the top level are still reported.

$schema = '{"type":"object","properties":{"top":{"type":"string"},"list":{"type":"array","items":{"type":"string","pattern":"^[a-z]+$"}}}}'

'{"top":1}' | Test-Json -Schema $schema -ErrorVariable e1 -ErrorAction SilentlyContinue
"errors: $($e1.Count)"; $e1 | % { "  $_" }

'{"list":["ok","NOT OK"]}' | Test-Json -Schema $schema -ErrorVariable e2 -ErrorAction SilentlyContinue
"errors: $($e2.Count)"; $e2 | % { "  $_" }
Expected behavior
PS 7.6.6
False
errors: 1
  The JSON is not valid with the schema: Value is "integer" but should be "string" at '/top'
False
errors: 1
  The JSON is not valid with the schema: The string value is not a match for the indicated regular expression at '/list/1'
Actual behavior
PS 7.6.7
False
errors: 1
  The JSON is not valid with the schema: Value is "integer" but should be "string" at '/top'
False
errors: 0
Error details
No error is written. That is the bug.
Environment data
Name                           Value
----                           -----
PSVersion                      7.6.7
PSEdition                      Core
GitCommitId                    7.6.7
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
Visuals

Likely cause: the 7.6.7 servicing change behind #28205 / #28214 ("Disable fetch delegate on $ref feature…") switched TestJsonCommand from OutputFormat.List to OutputFormat.Hierarchical without also backporting the recursive error reporting from master.

  • v7.6.6 evaluates with OutputFormat.List. That output is flat, so iterating evaluationResults.Details once reaches every error.
  • v7.6.7 evaluates with OutputFormat.Hierarchical (_evaluationOptions, line ~143), but ProcessRecord still calls HandleValidationErrors on the root and its direct Details only (lines ~287–295). Any error deeper than that, such as /list/1, is never written.
  • master also uses Hierarchical, but reports errors with a recursive ReportValidationErrors that descends into nestedResult.Details, so it does not have this problem.

Backporting the recursive ReportValidationErrors to release/v7.6 should fix it. It would also help to add a test that asserts an error is written for a nested or array-item violation.

Impact: scripts that use -ErrorVariable to show users why validation failed now get False with no details. We found this when our config-validation tests failed on the 7.6.7 upgrade.

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

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

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

PowerShell/PowerShell のほかの issue

PowerShell/PowerShell の issue をすべて見る

似ている issue

C# の issue をもっと見る

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

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