Test-Json in 7.6.7 writes no error for violations nested below the first level (e.g. array items)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 55/100
調査の方向性
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 の本文から書いたものです。
説明
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
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 iteratingevaluationResults.Detailsonce reaches every error. - v7.6.7 evaluates with
OutputFormat.Hierarchical(_evaluationOptions, line ~143), butProcessRecordstill callsHandleValidationErrorson the root and its directDetailsonly (lines ~287–295). Any error deeper than that, such as/list/1, is never written. - master also uses
Hierarchical, but reports errors with a recursiveReportValidationErrorsthat descends intonestedResult.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
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
PowerShell/PowerShell のほかの issue
-
Contributing tab on rendered Readme.md has broken links to two images, under .github/Images, but previews ok in .github/Contributing.md対応中かも @Soumilgit が 1 日前に担当しました。 オープンIssue-Enhancement Needs-Triage
難易度 1/5 1〜3時間 初心者へのやさしさ 68/100
PowerShell/PowerShell#28256 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Issue-Enhancement Needs-Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
PowerShell/PowerShell#28138 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Add support for WebRequestMethod QUERY対応中かも @soroshsabz が 30 日前に担当しました。 オープンIssue-Enhancement Up-for-Grabs WG-Cmdlets WG-Reviewed
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
PowerShell/PowerShell#28061 · コメント 3 件 · リアクション 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
PowerShell/PowerShell#28037 ·
メンテナーはふだん 1 日以内に返信
-
Test-Json returns wrong error when SchemaFile is not found対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンNeeds-Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
PowerShell/PowerShell#27973 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
PowerShell/PowerShell の issue をすべて見る
似ている issue
-
fix(testing): HeadlessTerminal disposes services synchronously対応中かも @zidad が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
RazorConsole/RazorConsole#388 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
starlinghq/starling#209 ·
メンテナーはふだん 1 日以内に返信
-
affected/v17 area/frontend type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
umbraco/Umbraco-CMS#24323 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
dotnet/roslynator#1859 ·
メンテナーはふだん 1 日以内に返信