Skip to content

Skip settings schema validation on PS5.1 when JSON exceeds command-line length limit#2231

Open
Copilot wants to merge 9 commits intomainfrom
copilot/fix-pwsh-exe-filename-warning
Open

Skip settings schema validation on PS5.1 when JSON exceeds command-line length limit#2231
Copilot wants to merge 9 commits intomainfrom
copilot/fix-pwsh-exe-filename-warning

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 30, 2026

❔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 on the PS5.1 code path when $settingsJson.Length > 30000. Uses continue instead of return to ensure subsequent piped settings objects are still validated. The PS7+ in-process Invoke-Command path is unaffected since it passes the JSON without command-line length constraints.

✅ Checklist

  • Add tests (E2E, unit tests) — added Pester test verifying oversized JSON skips pwsh invocation on PS5.1 and produces no warning
  • 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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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
Comment thread Actions/.Modules/ReadSettings.psm1
@mazhelez
Copy link
Copy Markdown
Collaborator

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 30, 2026

@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
# On PS7+, we can't trigger the PS5.1 code path directly.
# Instead, verify that ValidateSettings does NOT skip (uses Invoke-Command path).
# The schema validation will run in-process without hitting the length limit.
{ ValidateSettings -settings $settings } | Should -Not -Throw
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.

@copilot ValidateSettings never throws. At most it outputs a warning.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 15e5296 — removed the Should -Not -Throw wrappers and just call ValidateSettings directly.

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.

@copilot I think you need to verify that no warning is output

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a Should -Invoke -CommandName Write-Host -Times 0 -ParameterFilter { $Object -like '*::Warning::*' } assertion in 89a6b4a to verify no warning is output.

Copilot AI requested a review from mazhelez April 30, 2026 20:20
…versized JSON

Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/60d8dbf0-a9a5-4827-9ba8-7459f8bd422a

Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
The test should assert on OutputWarning (the function ValidateSettings
actually calls) rather than Write-Host (an internal implementation detail
of DebugLogHelper). Also removes unnecessary Out-Host mock.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mazhelez mazhelez enabled auto-merge (squash) May 1, 2026 12:37
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.

3 participants