Skip settings schema validation on PS5.1 when JSON exceeds command-line length limit#2231
Skip settings schema validation on PS5.1 when JSON exceeds command-line length limit#2231
Conversation
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>
Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/8ee7b1e9-d14b-41b8-b172-81c61ffe05c8 Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
There was a problem hiding this comment.
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. |
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/2daf92be-f2f4-44c9-a10c-46a1bd01e4c9 Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Applied all three changes from the review in commit bb500e1:
|
Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/a56d8a43-8737-4e44-a8d7-e0b0370497b9 Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
| # 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 |
There was a problem hiding this comment.
@copilot ValidateSettings never throws. At most it outputs a warning.
There was a problem hiding this comment.
Fixed in 15e5296 — removed the Should -Not -Throw wrappers and just call ValidateSettings directly.
There was a problem hiding this comment.
@copilot I think you need to verify that no warning is output
There was a problem hiding this comment.
Added a Should -Invoke -CommandName Write-Host -Times 0 -ParameterFilter { $Object -like '*::Warning::*' } assertion in 89a6b4a to verify no warning is output.
…s test Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/a6d20e17-ae77-432d-92ee-c96d102e2301 Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
…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>
❔What, Why & How
On PS5.1,
ValidateSettingsshells out topwsh.exepassing 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:Fix: Silently skip schema validation on the PS5.1 code path when
$settingsJson.Length > 30000. Usescontinueinstead ofreturnto ensure subsequent piped settings objects are still validated. The PS7+ in-processInvoke-Commandpath is unaffected since it passes the JSON without command-line length constraints.✅ Checklist