Repository navigation
Check mandatory worker parameters up front, and take a whole number as a code page - #72
Merged
Merged
Conversation
…s a code page - Invoke-PkRunspaceJobs refuses a job that leaves out a parameter the worker makes [Parameter(Mandatory)]: before anything starts for a fixed -JobParams list, as it arrives for -NextJobProvider. The job used to fail in binding and land in Errors while the rest ran. CancelToken is left out of the check (it's filled in), and so are workers with parameter sets, where what's needed depends on the set. - -OutputEncoding takes '65001' as a string as a code page, as from a CSV or config file, instead of refusing it as an unknown name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The mandatory-parameter check compares names case-insensitively, as binding does, so a case-sensitive [hashtable]::new() job isn't refused. One pass over the param block now collects both sets. - -OutputEncoding takes any whole number as a code page, such as the Int64 ConvertFrom-Json gives on PowerShell 7. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
Invoke-PkRunspaceJobschecks a fixed-JobParamslist before anything starts for keys the worker doesn't declare, but not for[Parameter(Mandatory)]ones a job leaves out. That job ran, failed in binding ("missing mandatory parameters: Name") and landed inErrorswhile the others ran.CrashedCountstayed 0, and-ResultHandlerwasn't called for it.-OutputEncoding '65001'as a string was refused. A code page read from a CSV or a config file is a string, andResolve-PkEncodingonly took a code page as an[int]. Anything else was looked up as a name and refused, with a message that said to use 65001. The same went for the Int64 thatConvertFrom-Jsongives on PowerShell 7.What changed
Invoke-PkRunspaceJobsrefuses a job that leaves out a mandatory parameter: before anything starts for-JobParams("... Nothing was started."), and as it arrives for-NextJobProvider, like the undeclared-key check. Names compare case-insensitively, as in binding.CancelTokenis left out of the check, since it's filled in when a job leaves it out. Workers with parameter sets aren't checked either, since what's needed depends on the set.Mandatory = $falsedoesn't count, and neither does aMandatoryvalue that isn't a constant; those are left to binding, as before.Resolve-PkEncodingtakes any whole number as a code page:'65001',' 437 ', an Int64. A string of digits that isn't a code page is still refused with the same message.How it was tested
New harness section BC, 9 assertions: a missing mandatory parameter is refused for
-JobParams(nothing runs) and for-NextJobProvider; a mandatoryCancelToken,Mandatory = $false, parameter sets and a case-sensitive hashtable aren't refused;'65001',' 437 'and an Int64 65001 resolve to their code pages;'99999999999'is still refused; and a program runs with-OutputEncoding '65001'.On the old code (main), the five assertions for the new behavior fail on both runtimes. Full harness on Windows PowerShell 5.1:
With this change, all 9 pass on both runtimes.
Full harness: Windows PowerShell 5.1
ALL PASSED (574 assertions), PowerShell 7ALL PASSED (574 assertions).🤖 Generated with Claude Code