Repository navigation
Closed
Labels
Resolution-FixedThe issue is fixed.The issue is fixed.
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
Since 7.6.7, 7.5.12 and 7.4.21, Test-Json can't use a schema whose $schema keyword is http://json-schema.org/schema. It writes UnresolvedJsonSchemaRef and returns False for any input, valid or not. With -ErrorAction SilentlyContinue, that False comes back with no output at all. Up to 7.6.6, 7.5.11 and 7.4.20 it validated the input normally.
# A concrete metaschema URI works in every version
Test-Json -Json '{}' -Schema '{ "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object" }'
# The http://json-schema.org/schema URI at the top level
Test-Json -Json '{}' -Schema '{ "$schema": "http://json-schema.org/schema", "type": "object" }'
# The same URI in a nested subschema, even though the input doesn't contain "a"
Test-Json -Json '{}' -Schema '{ "type": "object", "properties": { "a": { "$schema": "http://json-schema.org/schema" } } }'-SchemaFile behaves the same as -Schema.
Notes:
- The schemas contain no
$ref.Get-Errorshows the failure happens while resolving the$schemadialect (Json.Schema.SchemaRegistry.SetDialect), so the message about external references is misleading here. - Any
$schemavalue other than the exact draft-06, draft-07, 2019-09 and 2020-12 metaschema URIs fails the same way. That includes common variants such ashttps://json-schema.org/schemaand the http spelling of the 2020-12 URI,http://json-schema.org/draft/2020-12/schema. All of them work on 7.6.6. - Passing
-FetchExternalReferencerestores the old result (last command under "Actual behavior"), because the metaschema is then downloaded again. Earlier versions apparently did that download implicitly. - None of the release notes for v7.6.7, v7.5.12 and v7.4.21 mentions this change.
Could any of these be considered?
- Make the error say that the
$schemametaschema could not be resolved, rather than referring to external references. - Mention the change as a breaking change in the release notes.
- Resolve the json-schema.org metaschema URIs, including
http://json-schema.org/schema, without a network fetch.
Related: #28205 (and #28214, closed as its duplicate), and #28218 (a separate 7.6.7 Test-Json regression from the same servicing change).
Expected behavior
PS> Test-Json -Json '{}' -Schema '{ "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object" }'
True
PS> Test-Json -Json '{}' -Schema '{ "$schema": "http://json-schema.org/schema", "type": "object" }'
True
PS> Test-Json -Json '{}' -Schema '{ "type": "object", "properties": { "a": { "$schema": "http://json-schema.org/schema" } } }'
TrueActual behavior
PS> Test-Json -Json '{}' -Schema '{ "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object" }'
True
PS> Test-Json -Json '{}' -Schema '{ "$schema": "http://json-schema.org/schema", "type": "object" }'
Test-Json: The JSON schema contains a reference that could not be resolved. External schema references are not supported by default, use the 'FetchExternalReference' parameter to enable it.
False
PS> Test-Json -Json '{}' -Schema '{ "type": "object", "properties": { "a": { "$schema": "http://json-schema.org/schema" } } }'
Test-Json: The JSON schema contains a reference that could not be resolved. External schema references are not supported by default, use the 'FetchExternalReference' parameter to enable it.
False
PS> Test-Json -Json '{}' -Schema '{ "$schema": "http://json-schema.org/schema", "type": "object" }' -FetchExternalReference
TrueError details
PS> Get-Error
Exception :
Type : System.Exception
Message : The JSON schema contains a reference that could not be resolved. External schema references are not supported by default, use the 'FetchExternalReference' parameter to enable it.
InnerException :
Type : Json.Schema.RefResolutionException
BaseUri : http://json-schema.org/schema
TargetSite :
Name : SetDialect
DeclaringType : [Json.Schema.SchemaRegistry]
MemberType : Method
Module : JsonSchema.Net.dll
Message : Could not resolve 'http://json-schema.org/schema'
Source : JsonSchema.Net
HResult : -2146233088
StackTrace :
at Json.Schema.SchemaRegistry.SetDialect(JsonSchema schema, Vocabulary[] parentDialect)
at Json.Schema.SchemaRegistry.Scan(Uri baseUri, JsonSchema document)
at Json.Schema.SchemaRegistry.RegisterSchema(Uri uri, IBaseDocument document)
at Json.Schema.JsonSchema.Evaluate(JsonNode root, EvaluationOptions options)
at Microsoft.PowerShell.Commands.TestJsonCommand.ProcessRecord()
HResult : -2146233088
TargetObject : Json.Schema.JsonSchema
CategoryInfo : InvalidData: (Json.Schema.JsonSchema:JsonSchema) [Test-Json], Exception
FullyQualifiedErrorId : UnresolvedJsonSchemaRef,Microsoft.PowerShell.Commands.TestJsonCommand
InvocationInfo :
MyCommand : Test-Json
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 1
Line : Test-Json -Json '{}' -Schema '{ "$schema": "http://json-schema.org/schema", "type": "object" }'
Statement : Test-Json -Json '{}' -Schema '{ "$schema": "http://json-schema.org/schema", "type": "object" }'
PositionMessage : At line:1 char:1
+ Test-Json -Json '{}' -Schema '{ "$schema": "http://json-schema.org/sc …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : Test-Json
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :
0
1Environment data
Name Value
---- -----
PSVersion 7.6.7
PSEdition Core
GitCommitId 7.6.7
OS Ubuntu 24.04.2 LTS
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.4
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
No response
Metadata
Metadata
Assignees
Labels
Resolution-FixedThe issue is fixed.The issue is fixed.
Activity
mklement0 commentedon Oct 22, 2026
FWIW, while the problem still exists in the current stable version, v7.6.7, it no longer does in the current preview version, v7.7.0-preview.5.
daxian-dbw commentedon Oct 28, 2026
Fixed by #28273