Skip settings schema validation on PowerShell versions less than 7#2231
Skip settings schema validation on PowerShell versions less than 7#2231Copilot wants to merge 20 commits into
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>
…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>
Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/d00cb97b-e021-433d-8b52-e273feee35d9 Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
|
@copilot can you please make sure the tests are up to date as well? |
Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/a63ef1b2-fef1-459b-9f09-15a78c86ce98 Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
|
@copilot when I try to update the PR branch, I get the following error: "Head branch was modified. Review and try the merge again." Please investigate and eventually update the branch. |
|
@copilot please fix the failing tests |
The test was failing on PS5 because |
| It 'ValidateSettings skips validation entirely on PS versions less than 7 without warning' { | ||
| Mock OutputWarning { } | ||
|
|
||
| $settings = @{ "someProp" = "someValue" } | ||
|
|
||
| if ($PSVersionTable.PSVersion.Major -ge 7) { | ||
| Mock Test-Json { } | ||
| ValidateSettings -settings $settings | ||
| # On PS7+, Test-Json is called directly for validation | ||
| Should -Invoke -CommandName Test-Json -Times 1 | ||
| } | ||
| else { | ||
| # On PS < 7, validation is skipped entirely; Test-Json doesn't exist so we just verify no warning | ||
| ValidateSettings -settings $settings | ||
| } | ||
|
|
||
| # Verify no warning was output | ||
| Should -Invoke -CommandName OutputWarning -Times 0 | ||
| } |
❔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 entirely when
$PSVersionTable.PSVersion.Major -lt 7. TheValidateSettingsfunction now performs a hardreturnat the very beginning of itsProcessblock on PS < 7, avoiding any JSON serialization orpwshinvocation. On PS7+,Test-Jsonis called directly (the previousInvoke-Commandwrapper has been removed since it's no longer needed with the early exit guard).✅ Checklist
Test-Jsonis called on PS7+ and skipped on PS < 7, with no warnings produced