Skip to content

Skip settings schema validation on PowerShell versions less than 7#2231

Merged
mazhelez merged 25 commits into
mainfrom
copilot/fix-pwsh-exe-filename-warning
Jul 9, 2026
Merged

Skip settings schema validation on PowerShell versions less than 7#2231
mazhelez merged 25 commits into
mainfrom
copilot/fix-pwsh-exe-filename-warning

Conversation

Copilot AI commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

❔What, Why & How

On PS5.1, ValidateSettings shells out to pwsh.exe passing the full settings JSON as a command-line argument. For repositories with many projects/settings, the JSON can exceed the ~32K Windows command-line limit, producing:

Error validating settings. Error: Program 'pwsh.exe' failed to run: The filename or extension is too long

Fix: Silently skip schema validation entirely when $PSVersionTable.PSVersion.Major -lt 7. The ValidateSettings function now performs a hard return at the very beginning of its Process block on PS < 7, avoiding any JSON serialization or pwsh invocation. On PS7+, Test-Json is called directly (the previous Invoke-Command wrapper has been removed since it's no longer needed with the early exit guard).

✅ Checklist

  • Add tests (E2E, unit tests) — added Pester test verifying Test-Json is called on PS7+ and skipped on PS < 7, with no warnings produced
  • Update RELEASENOTES.md
  • Update documentation (e.g. for new settings or scenarios)
  • Add telemetry

Copilot AI and others added 3 commits April 30, 2026 13:31
Write settings JSON to a temp file instead of passing it as a
command-line argument to pwsh.exe, which exceeds the Windows
command-line length limit (~32K chars) for large settings.

Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/90f81e6b-6fa6-4fa5-9a16-4c43637c704d

Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
…th limit

Instead of writing to a temp file, simply skip the validation when
the settings JSON is too large (>30K chars) for the Windows
command-line limit.

Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/333f25d2-8e08-4ebf-8b95-fc6fe2001579

Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
@mazhelez mazhelez marked this pull request as ready for review April 30, 2026 13:51
@mazhelez mazhelez requested a review from a team as a code owner April 30, 2026 13:51
Copilot AI review requested due to automatic review settings April 30, 2026 13:51

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.

Pull request overview

This PR addresses a Windows PowerShell 5.1 limitation where ValidateSettings shells out to pwsh and can exceed the Windows ~32K command-line length limit when passing large settings JSON, causing validation to fail.

Changes:

  • Add a PS5.1 guard to skip settings schema validation when the serialized settings JSON is larger than 30,000 characters.
  • Update release notes to document the fix for the “filename or extension is too long” validation error.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
RELEASENOTES.md Documents the PS5.1 validation-length-limit fix in the Issues list.
Actions/.Modules/ReadSettings.psm1 Adds an early-exit condition in ValidateSettings for PS5.1 when settings JSON is very large.

Comment thread Actions/.Modules/ReadSettings.psm1 Outdated
Comment thread Actions/.Modules/ReadSettings.psm1 Outdated
Comment thread Actions/.Modules/ReadSettings.psm1 Outdated
@mazhelez

Copy link
Copy Markdown
Collaborator

@copilot apply changes based on the comments in this thread

Copilot AI commented Apr 30, 2026

Copy link
Copy Markdown
Contributor Author

@copilot apply changes based on the comments in this thread

Applied all three changes from the review in commit bb500e1:

  1. Changed returncontinue in the Process block so subsequent piped items still get validated.
  2. Added an OutputWarning explaining that schema validation was skipped due to the PS5.1 command-line length limit.
  3. Added a unit test in Tests/ReadSettings.Test.ps1 that verifies oversized JSON skips validation (with warning on PS5.1, or runs in-process without skipping on PS7+). All 12 ReadSettings tests pass.

Copilot AI requested a review from mazhelez April 30, 2026 15:05
Comment thread Actions/.Modules/ReadSettings.psm1 Outdated
Copilot AI requested a review from mazhelez April 30, 2026 20:14
Comment thread Tests/ReadSettings.Test.ps1 Outdated
Copilot AI requested a review from mazhelez April 30, 2026 20:20

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread Tests/ReadSettings.Test.ps1
aholstrup1
aholstrup1 previously approved these changes Jul 2, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@mazhelez

mazhelez commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Resolved in the latest commit — merged main into the branch, keeping both the existing ValidateSettings test and the new doNotPerformUpgrade schema test added by main.

spetersenms
spetersenms previously approved these changes Jul 6, 2026
@mazhelez

mazhelez commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Resolved in the latest commit — merged main into the branch. The doNotPerformUpgrade test was removed since that setting was reverted from main; only the ValidateSettings skip test remains.

Comment thread RELEASENOTES.md Outdated

@aholstrup1 aholstrup1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Releasenote is off

Comment thread RELEASENOTES.md Outdated
@mazhelez mazhelez merged commit ff14855 into main Jul 9, 2026
8 checks passed
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.

5 participants