Skip to content

Test-Json | Fix error message when schema file is not found - #27974

Open
PRASOON KARUNAN V (kvprasoon) wants to merge 8 commits into
PowerShell:masterfrom
kvprasoon:fix/issue-27973-jsonschema
Open

PRASOON KARUNAN V (kvprasoon) wants to merge 8 commits into
PowerShell:masterfrom
kvprasoon:fix/issue-27973-jsonschema

Conversation

@kvprasoon

Copy link
Copy Markdown
Contributor

PR Summary

Test-Json returns incorrect error message when SchemaFile is not present.

PR Context

This PR has the changes to throw proper error message when the SchemaFile is not found.

PR Checklist

Copilot AI lite review requested due to automatic review settings September 4, 2026 17:30
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 with JsonSchemaFileNotFound when schema loading throws FileNotFoundException.
  • Update Pester tests to expect the new JsonSchemaFileNotFound error 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants