Repository navigation
Description
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: 0Error 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.0Visuals
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.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsReviewed
Activity
TaekeK commentedon Oct 16, 2026
The same regression also hits schema composition, not only nested instance locations. A failing
if/theninsideallOfwrites no error on 7.6.7. At the top level it still does:This breaks the common
try { Test-Json ... -ErrorAction Stop } catch { invalid }pattern as well as-ErrorVariable. No exception is raised, so the document is treated as valid. The recursive reporting suggested above should cover this case too, since theallOf→then→requiredresult sits two levels below the root.UncleBats commentedon Oct 20, 2026
The recursive error reporting on
mastercame from #26618 ("Fix Test-Json false positive errors when using oneOf or anyOf in schema", merged Dec 2025). It was never backported to 7.6.x.That didn't matter in v7.6.6. There,
TestJsonCommandevaluates withOutputFormat.List, which returns every error flat under the root, so checking the root and its directDetailsfinds them all. The shipped v7.6.7 tag evaluates withOutputFormat.Hierarchical, butProcessRecordstill callsHandleValidationErrorsonly on the root and its directDetails. Errors nested deeper, such as/list/1orallOf→then→required, are never reported. (Therelease/v7.6.7branch on GitHub still showsOutputFormat.List. Only the v7.6.7 tag has the switch.)Could the maintainers consider backporting #26618 to 7.6.x, together with the #28205 servicing change? A regression test that asserts an error is written for an array-item violation and for a nested
if/theninsideallOfwould help keep this from coming back.SteveL-MSFT commentedon Oct 21, 2026
PowerShell team is aware of this regression and will be fixed in the next servicing release of 7.6
daxian-dbw commentedon Oct 28, 2026
Fixed by #28273