From d2f34de499e2a2d3ec283c1015a2278a851a91b9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 30 Apr 2026 13:31:05 +0000 Subject: [PATCH 01/11] Fix command-line too long error when validating settings on PS5.1 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> --- Actions/.Modules/ReadSettings.psm1 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Actions/.Modules/ReadSettings.psm1 b/Actions/.Modules/ReadSettings.psm1 index ea3bbe350..54792a218 100644 --- a/Actions/.Modules/ReadSettings.psm1 +++ b/Actions/.Modules/ReadSettings.psm1 @@ -604,7 +604,21 @@ function ValidateSettings { } if($PSVersionTable.PSVersion.Major -lt 6) { # Test-Json is not available in PS5.1 - $result = pwsh -noprofile -Command $command -args $settingsJson, $settingsSchemaFile + # Write JSON to a temp file to avoid exceeding the Windows command-line length limit + $tempJsonFile = [System.IO.Path]::GetTempFileName() + try { + [System.IO.File]::WriteAllText($tempJsonFile, $settingsJson, [System.Text.Encoding]::UTF8) + $fileCommand = [scriptblock] { + $jsonContent = [System.IO.File]::ReadAllText($args[0], [System.Text.Encoding]::UTF8) + $result = '' + Test-Json -Json $jsonContent -SchemaFile $args[1] -ErrorVariable result -ErrorAction SilentlyContinue | Out-Null + return $result + } + $result = pwsh -noprofile -Command $fileCommand -args $tempJsonFile, $settingsSchemaFile + } + finally { + Remove-Item -Path $tempJsonFile -Force -ErrorAction SilentlyContinue + } } else { $result = Invoke-Command -ScriptBlock $command -ArgumentList $settingsJson, $settingsSchemaFile From 49b0633dc0bc1d3f327314208bf60a5b31c3c432 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 30 Apr 2026 13:45:58 +0000 Subject: [PATCH 02/11] Skip settings validation on PS5.1 when JSON exceeds command-line length 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> --- Actions/.Modules/ReadSettings.psm1 | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/Actions/.Modules/ReadSettings.psm1 b/Actions/.Modules/ReadSettings.psm1 index 54792a218..a2b94072a 100644 --- a/Actions/.Modules/ReadSettings.psm1 +++ b/Actions/.Modules/ReadSettings.psm1 @@ -604,21 +604,11 @@ function ValidateSettings { } if($PSVersionTable.PSVersion.Major -lt 6) { # Test-Json is not available in PS5.1 - # Write JSON to a temp file to avoid exceeding the Windows command-line length limit - $tempJsonFile = [System.IO.Path]::GetTempFileName() - try { - [System.IO.File]::WriteAllText($tempJsonFile, $settingsJson, [System.Text.Encoding]::UTF8) - $fileCommand = [scriptblock] { - $jsonContent = [System.IO.File]::ReadAllText($args[0], [System.Text.Encoding]::UTF8) - $result = '' - Test-Json -Json $jsonContent -SchemaFile $args[1] -ErrorVariable result -ErrorAction SilentlyContinue | Out-Null - return $result - } - $result = pwsh -noprofile -Command $fileCommand -args $tempJsonFile, $settingsSchemaFile - } - finally { - Remove-Item -Path $tempJsonFile -Force -ErrorAction SilentlyContinue + # Skip validation if the settings JSON is too large for the Windows command-line length limit + if ($settingsJson.Length -gt 30000) { + return } + $result = pwsh -noprofile -Command $command -args $settingsJson, $settingsSchemaFile } else { $result = Invoke-Command -ScriptBlock $command -ArgumentList $settingsJson, $settingsSchemaFile From e9b4c48213428a88026fe3e5d638e2a035affe6b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 30 Apr 2026 13:48:50 +0000 Subject: [PATCH 03/11] Add release note for PS5.1 settings validation fix 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> --- RELEASENOTES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index ab0eec036..7b4eaaf7a 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -8,6 +8,7 @@ The `DownloadProjectDependencies` action now downloads only artifacts from depen - Issue 2204 - Workspace compilation ignores vsixFile setting - Issue 2211 - Cannot create a release if a project contains only test apps - Issue 2214 - Workspace compilation not working with external dependencies +- Fix "filename or extension is too long" error when validating settings on PS5.1 with large settings JSON ## v9.0 From bb500e18f19dbaab4c43d0b4480bb894ed178bf3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 30 Apr 2026 15:04:44 +0000 Subject: [PATCH 04/11] Address review: add warning on skip, use continue, add unit test 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> --- Actions/.Modules/ReadSettings.psm1 | 3 ++- Tests/ReadSettings.Test.ps1 | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Actions/.Modules/ReadSettings.psm1 b/Actions/.Modules/ReadSettings.psm1 index a2b94072a..8dada52a2 100644 --- a/Actions/.Modules/ReadSettings.psm1 +++ b/Actions/.Modules/ReadSettings.psm1 @@ -606,7 +606,8 @@ function ValidateSettings { if($PSVersionTable.PSVersion.Major -lt 6) { # Test-Json is not available in PS5.1 # Skip validation if the settings JSON is too large for the Windows command-line length limit if ($settingsJson.Length -gt 30000) { - return + OutputWarning "Schema validation was skipped because the serialized settings JSON is too large for the PowerShell 5.1 command-line fallback. Run under pwsh / PowerShell 7+ to validate settings in-process." + continue } $result = pwsh -noprofile -Command $command -args $settingsJson, $settingsSchemaFile } diff --git a/Tests/ReadSettings.Test.ps1 b/Tests/ReadSettings.Test.ps1 index 24fdb69c9..b11c58091 100644 --- a/Tests/ReadSettings.Test.ps1 +++ b/Tests/ReadSettings.Test.ps1 @@ -519,5 +519,33 @@ InModuleScope ReadSettings { # Allows testing of private functions Pop-Location Remove-Item -Path $tempName -Recurse -Force } + + It 'ValidateSettings skips validation and emits warning on PS5.1 when JSON exceeds 30000 chars' { + Mock Write-Host { } + Mock Out-Host { } + Mock OutputWarning { } -Verifiable + + # Build a settings hashtable whose JSON serialization exceeds 30000 characters + $largeValue = 'x' * 31000 + $settings = @{ "largeProp" = $largeValue } + + if ($PSVersionTable.PSVersion.Major -ge 6) { + # 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 + Should -Invoke -CommandName OutputWarning -Times 0 -ParameterFilter { $message -like '*Schema validation was skipped*' } + } + else { + # On PS5.1, shadow pwsh so that if it is called, the test fails + Mock pwsh { throw "pwsh should not be called for oversized JSON" } + + # Run ValidateSettings - should not throw + { ValidateSettings -settings $settings } | Should -Not -Throw + + # Verify the warning was emitted + Should -Invoke -CommandName OutputWarning -ParameterFilter { $message -like '*Schema validation was skipped*' } -Times 1 + } + } } } From 9bb017c82f0cba9c787564ee71fbd50439ca1fc2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 30 Apr 2026 20:13:26 +0000 Subject: [PATCH 05/11] Remove warning when skipping schema validation on PS5.1 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> --- Actions/.Modules/ReadSettings.psm1 | 1 - Tests/ReadSettings.Test.ps1 | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Actions/.Modules/ReadSettings.psm1 b/Actions/.Modules/ReadSettings.psm1 index 8dada52a2..a97bbce2b 100644 --- a/Actions/.Modules/ReadSettings.psm1 +++ b/Actions/.Modules/ReadSettings.psm1 @@ -606,7 +606,6 @@ function ValidateSettings { if($PSVersionTable.PSVersion.Major -lt 6) { # Test-Json is not available in PS5.1 # Skip validation if the settings JSON is too large for the Windows command-line length limit if ($settingsJson.Length -gt 30000) { - OutputWarning "Schema validation was skipped because the serialized settings JSON is too large for the PowerShell 5.1 command-line fallback. Run under pwsh / PowerShell 7+ to validate settings in-process." continue } $result = pwsh -noprofile -Command $command -args $settingsJson, $settingsSchemaFile diff --git a/Tests/ReadSettings.Test.ps1 b/Tests/ReadSettings.Test.ps1 index b11c58091..7dd28dc4b 100644 --- a/Tests/ReadSettings.Test.ps1 +++ b/Tests/ReadSettings.Test.ps1 @@ -520,10 +520,9 @@ InModuleScope ReadSettings { # Allows testing of private functions Remove-Item -Path $tempName -Recurse -Force } - It 'ValidateSettings skips validation and emits warning on PS5.1 when JSON exceeds 30000 chars' { + It 'ValidateSettings skips pwsh invocation on PS5.1 when JSON exceeds 30000 chars' { Mock Write-Host { } Mock Out-Host { } - Mock OutputWarning { } -Verifiable # Build a settings hashtable whose JSON serialization exceeds 30000 characters $largeValue = 'x' * 31000 @@ -534,7 +533,6 @@ InModuleScope ReadSettings { # Allows testing of private functions # 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 - Should -Invoke -CommandName OutputWarning -Times 0 -ParameterFilter { $message -like '*Schema validation was skipped*' } } else { # On PS5.1, shadow pwsh so that if it is called, the test fails @@ -543,8 +541,8 @@ InModuleScope ReadSettings { # Allows testing of private functions # Run ValidateSettings - should not throw { ValidateSettings -settings $settings } | Should -Not -Throw - # Verify the warning was emitted - Should -Invoke -CommandName OutputWarning -ParameterFilter { $message -like '*Schema validation was skipped*' } -Times 1 + # Verify pwsh was NOT called + Should -Invoke -CommandName pwsh -Times 0 } } } From 15e5296fe8839735e84516ce0975f213e7eb9318 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 30 Apr 2026 20:19:31 +0000 Subject: [PATCH 06/11] Remove unnecessary Should -Not -Throw assertions from ValidateSettings 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> --- Tests/ReadSettings.Test.ps1 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Tests/ReadSettings.Test.ps1 b/Tests/ReadSettings.Test.ps1 index 7dd28dc4b..ec3bb789a 100644 --- a/Tests/ReadSettings.Test.ps1 +++ b/Tests/ReadSettings.Test.ps1 @@ -529,17 +529,14 @@ InModuleScope ReadSettings { # Allows testing of private functions $settings = @{ "largeProp" = $largeValue } if ($PSVersionTable.PSVersion.Major -ge 6) { - # 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 + # On PS7+, the Invoke-Command path is used in-process without length limits. + ValidateSettings -settings $settings } else { # On PS5.1, shadow pwsh so that if it is called, the test fails Mock pwsh { throw "pwsh should not be called for oversized JSON" } - # Run ValidateSettings - should not throw - { ValidateSettings -settings $settings } | Should -Not -Throw + ValidateSettings -settings $settings # Verify pwsh was NOT called Should -Invoke -CommandName pwsh -Times 0 From 89a6b4a5721d2804c62e6db01f119a51556f0039 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 30 Apr 2026 20:35:12 +0000 Subject: [PATCH 07/11] Add assertion that no warning is output when ValidateSettings skips oversized 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> --- Tests/ReadSettings.Test.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Tests/ReadSettings.Test.ps1 b/Tests/ReadSettings.Test.ps1 index ec3bb789a..2b3877da3 100644 --- a/Tests/ReadSettings.Test.ps1 +++ b/Tests/ReadSettings.Test.ps1 @@ -520,7 +520,7 @@ InModuleScope ReadSettings { # Allows testing of private functions Remove-Item -Path $tempName -Recurse -Force } - It 'ValidateSettings skips pwsh invocation on PS5.1 when JSON exceeds 30000 chars' { + It 'ValidateSettings skips pwsh invocation on PS5.1 when JSON exceeds 30000 chars without warning' { Mock Write-Host { } Mock Out-Host { } @@ -541,6 +541,9 @@ InModuleScope ReadSettings { # Allows testing of private functions # Verify pwsh was NOT called Should -Invoke -CommandName pwsh -Times 0 } + + # Verify no warning was output + Should -Invoke -CommandName Write-Host -Times 0 -ParameterFilter { $Object -like '*::Warning::*' } } } } From b320ab623609aa43a0c68df9702bd8904ddc8d0f Mon Sep 17 00:00:00 2001 From: Maria Zhelezova <43066499+mazhelez@users.noreply.github.com> Date: Fri, 1 May 2026 13:07:22 +0200 Subject: [PATCH 08/11] Fix test to mock OutputWarning instead of Write-Host 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> --- Tests/ReadSettings.Test.ps1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Tests/ReadSettings.Test.ps1 b/Tests/ReadSettings.Test.ps1 index 2b3877da3..08f168d23 100644 --- a/Tests/ReadSettings.Test.ps1 +++ b/Tests/ReadSettings.Test.ps1 @@ -521,8 +521,7 @@ InModuleScope ReadSettings { # Allows testing of private functions } It 'ValidateSettings skips pwsh invocation on PS5.1 when JSON exceeds 30000 chars without warning' { - Mock Write-Host { } - Mock Out-Host { } + Mock OutputWarning { } # Build a settings hashtable whose JSON serialization exceeds 30000 characters $largeValue = 'x' * 31000 @@ -543,7 +542,7 @@ InModuleScope ReadSettings { # Allows testing of private functions } # Verify no warning was output - Should -Invoke -CommandName Write-Host -Times 0 -ParameterFilter { $Object -like '*::Warning::*' } + Should -Invoke -CommandName OutputWarning -Times 0 } } } From d3d942c12ee6cba17b2653111c8d01906997cf89 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 May 2026 08:31:42 +0000 Subject: [PATCH 09/11] Skip validation entirely on PS < 7 instead of only for oversized JSON Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/73ceb4f7-4660-47fa-818e-8b464addd475 Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com> --- Actions/.Modules/ReadSettings.psm1 | 8 ++------ Tests/ReadSettings.Test.ps1 | 14 ++++++-------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/Actions/.Modules/ReadSettings.psm1 b/Actions/.Modules/ReadSettings.psm1 index 14ed1f372..169f30a1c 100644 --- a/Actions/.Modules/ReadSettings.psm1 +++ b/Actions/.Modules/ReadSettings.psm1 @@ -606,12 +606,8 @@ function ValidateSettings { return $result } - if($PSVersionTable.PSVersion.Major -lt 6) { # Test-Json is not available in PS5.1 - # Skip validation if the settings JSON is too large for the Windows command-line length limit - if ($settingsJson.Length -gt 30000) { - continue - } - $result = pwsh -noprofile -Command $command -args $settingsJson, $settingsSchemaFile + if($PSVersionTable.PSVersion.Major -lt 7) { + continue } else { $result = Invoke-Command -ScriptBlock $command -ArgumentList $settingsJson, $settingsSchemaFile diff --git a/Tests/ReadSettings.Test.ps1 b/Tests/ReadSettings.Test.ps1 index 455650fcb..c38a7f03a 100644 --- a/Tests/ReadSettings.Test.ps1 +++ b/Tests/ReadSettings.Test.ps1 @@ -541,20 +541,18 @@ InModuleScope ReadSettings { # Allows testing of private functions Remove-Item -Path $tempName -Recurse -Force } - It 'ValidateSettings skips pwsh invocation on PS5.1 when JSON exceeds 30000 chars without warning' { + It 'ValidateSettings skips validation entirely on PS versions less than 7 without warning' { Mock OutputWarning { } - # Build a settings hashtable whose JSON serialization exceeds 30000 characters - $largeValue = 'x' * 31000 - $settings = @{ "largeProp" = $largeValue } + $settings = @{ "someProp" = "someValue" } - if ($PSVersionTable.PSVersion.Major -ge 6) { - # On PS7+, the Invoke-Command path is used in-process without length limits. + if ($PSVersionTable.PSVersion.Major -ge 7) { + # On PS7+, the Invoke-Command path is used in-process. ValidateSettings -settings $settings } else { - # On PS5.1, shadow pwsh so that if it is called, the test fails - Mock pwsh { throw "pwsh should not be called for oversized JSON" } + # On PS < 7, validation is skipped entirely; pwsh should never be called + Mock pwsh { throw "pwsh should not be called on PS < 7" } ValidateSettings -settings $settings From 31d6b40f31c15359c7d69218346efe84083f79a1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 May 2026 08:54:40 +0000 Subject: [PATCH 10/11] Move PS version check to hard exit at beginning of ValidateSettings function Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/9e9cfcd2-5c9d-442a-aa5b-5814047ed25d Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com> --- Actions/.Modules/ReadSettings.psm1 | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Actions/.Modules/ReadSettings.psm1 b/Actions/.Modules/ReadSettings.psm1 index 169f30a1c..df4284a7d 100644 --- a/Actions/.Modules/ReadSettings.psm1 +++ b/Actions/.Modules/ReadSettings.psm1 @@ -595,6 +595,10 @@ function ValidateSettings { $settings ) Process { + if ($PSVersionTable.PSVersion.Major -lt 7) { + return + } + $settingsJson = ConvertTo-Json -InputObject $settings -Depth 99 -Compress $settingsSchemaFile = Join-Path $PSScriptRoot "settings.schema.json" -Resolve @@ -606,12 +610,7 @@ function ValidateSettings { return $result } - if($PSVersionTable.PSVersion.Major -lt 7) { - continue - } - else { - $result = Invoke-Command -ScriptBlock $command -ArgumentList $settingsJson, $settingsSchemaFile - } + $result = Invoke-Command -ScriptBlock $command -ArgumentList $settingsJson, $settingsSchemaFile } catch { OutputWarning "Error validating settings. Error: $($_.Exception.Message)" From ce68b2de125a9304a548ed65580cf1094b9f9315 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 May 2026 09:26:00 +0000 Subject: [PATCH 11/11] Remove Invoke-Command wrapper since PS<7 now exits early 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> --- Actions/.Modules/ReadSettings.psm1 | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Actions/.Modules/ReadSettings.psm1 b/Actions/.Modules/ReadSettings.psm1 index df4284a7d..99e47fd1f 100644 --- a/Actions/.Modules/ReadSettings.psm1 +++ b/Actions/.Modules/ReadSettings.psm1 @@ -604,13 +604,7 @@ function ValidateSettings { $result = "" try{ - $command = [scriptblock] { - $result = '' - Test-Json -Json $args[0] -SchemaFile $args[1] -ErrorVariable result -ErrorAction SilentlyContinue | Out-Null - return $result - } - - $result = Invoke-Command -ScriptBlock $command -ArgumentList $settingsJson, $settingsSchemaFile + Test-Json -Json $settingsJson -SchemaFile $settingsSchemaFile -ErrorVariable result -ErrorAction SilentlyContinue | Out-Null } catch { OutputWarning "Error validating settings. Error: $($_.Exception.Message)"