Test-Json | Fix error message when schema file is not found - #27974
Open
PRASOON KARUNAN V (kvprasoon) wants to merge 8 commits into
Open
PRASOON KARUNAN V (kvprasoon) wants to merge 8 commits into
PRASOON KARUNAN V (kvprasoon) wants to merge 8 commits into
Conversation
PRASOON KARUNAN V (kvprasoon)
requested a review
from a team
as a code owner
September 4, 2026 17:30
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Copilot started reviewing on behalf of
PRASOON KARUNAN V (kvprasoon)
September 4, 2026 17:32
View session
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Missing-directory/missing-drive schema paths still map to the open-failure error, and the updated test doesn’t validate the corrected user-facing error message text.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR addresses #27973 by improving Test-Json’s handling of missing -SchemaFile inputs so the cmdlet emits a more accurate, user-facing error (and associated error id) when a schema file path doesn’t exist.
Changes:
- Add a new localized resource string for “schema file not found” and adjust existing open-failure wording (“Can not” → “Cannot”).
- Update
TestJsonCommand.BeginProcessing()to terminate withJsonSchemaFileNotFoundwhen schema loading throwsFileNotFoundException. - Update Pester tests to expect the new
JsonSchemaFileNotFounderror id for missing schema files.
File summaries
| File | Description |
|---|---|
| test/powershell/Modules/Microsoft.PowerShell.Utility/Test-Json.Tests.ps1 | Updates Pester expectations for the new SchemaFile-not-found error id. |
| src/Microsoft.PowerShell.Commands.Utility/resources/TestJsonCmdletStrings.resx | Adds the new “Cannot find JSON schema file” resource and tweaks open-failure wording. |
| src/Microsoft.PowerShell.Commands.Utility/commands/utility/TestJsonCommand.cs | Adds a not-found terminating error path for missing schema files. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
…soon/powershell into fix/issue-27973-jsonschema
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Test-Jsonreturns incorrect error message whenSchemaFileis not present.PR Context
This PR has the changes to throw proper error message when the
SchemaFileis not found.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header