Skip to content

Check mandatory worker parameters up front, and take a whole number as a code page - #72

Merged
HalRiveria-Bot merged 2 commits into
mainfrom
fix/up-front-checks
Nov 19, 2026
Merged

HalRiveria-Bot merged 2 commits into
mainfrom
fix/up-front-checks

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

What was wrong

  • A worker missing a mandatory parameter wasn't caught up front. Invoke-PkRunspaceJobs checks a fixed -JobParams list 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 in Errors while the others ran. CrashedCount stayed 0, and -ResultHandler wasn'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, and Resolve-PkEncoding only 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 that ConvertFrom-Json gives on PowerShell 7.

What changed

  • Invoke-PkRunspaceJobs refuses 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. CancelToken is 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 = $false doesn't count, and neither does a Mandatory value that isn't a constant; those are left to binding, as before.
  • Resolve-PkEncoding takes 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.
  • Help and README updated for both.

How it was tested

New harness section BC, 9 assertions: a missing mandatory parameter is refused for -JobParams (nothing runs) and for -NextJobProvider; a mandatory CancelToken, 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:

[FAIL] -JobParams: a job missing a mandatory parameter is refused before anything starts (; ran 1)
[FAIL] -NextJobProvider: a job missing a mandatory parameter is refused as it arrives ()
[FAIL] -OutputEncoding '65001' as a string is taken as code page 65001, like the number (refused, refused, 65001, refused)
[FAIL] so is 65001 as an Int64, as ConvertFrom-Json gives it on PowerShell 7 (refused)
[FAIL] a program runs with -OutputEncoding '65001' ('OutputEncoding '65001' isn't an encoding .NET knows. Use a name like 'utf-8' or 'windows-1252', or a code page number like 65001.')
5 FAILED, 569 passed

With this change, all 9 pass on both runtimes.

Full harness: Windows PowerShell 5.1 ALL PASSED (574 assertions), PowerShell 7 ALL PASSED (574 assertions).

🤖 Generated with Claude Code

HalRiveria and others added 2 commits November 18, 2026 16:28
…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>
@HalRiveria-Bot
HalRiveria-Bot merged commit e56c7e2 into main Nov 19, 2026
2 checks passed
@HalRiveria-Bot
HalRiveria-Bot deleted the fix/up-front-checks branch November 19, 2026 00:34
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.

2 participants