shmuelie / shmuelie/powershell-modules

Canonical .NET tool commands suppress native discovery and update failures

Open
#276 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug module:dotnet module:utilities theme:testing
Dominant language
PowerShell
Stars
0
Forks
0
Avg merge
21m
Merged PRs (30d)
124

Description

Peer-review finding

Reviewed snapshot: 5c38677469756c69f86678c0b907d82e15d0a539.
The parent independently replayed this finding using only synthetic fixtures and
harmless native children. No actual package operation or credential access was
performed, and no repository source was changed.

Severity: medium. Confidence: 10/10.
Existing labels: bug, module:dotnet, module:utilities.

Source at the reviewed commit:
modules\Shmuelie.DotNet\DotNetHelpers.ps1:30-45,88-104.
Forwarding entry points:
modules\Shmuelie.Utilities\DotNetHelpers.ps1:59-72,111-124.
The aggregate separately compensates in
modules\Shmuelie.PackageManagement\DotNetPackageProvider.ps1:1-22.

Cause and reachable impact: the canonical list command discards stderr and
never checks the native exit code; the update command moves diagnostics to
verbose output, parses them as if the invocation completed, and emits an
ordinary DotNetToolUpdateResult without checking native success. With
PSNativeCommandUseErrorActionPreference = $false (the normal opt-in native
error setting), even -ErrorAction Stop cannot make these failures visible as
PowerShell errors. Scripts can interpret a failed inventory as no installed
tools or a failed update as an unchanged tool and continue subsequent work.
Both lazy compatibility wrappers faithfully inherit the defect; this is not a
wrapper forwarding defect. The aggregate's explicit exit-code guard protects
its own path, so do not file this as a broken aggregate failure boundary.

Safe reproduction: the .NET cases in Repro-Candidates.ps1. The source
module's dotnet function is replaced by a fake that launches only fresh
pwsh -NoProfile -NonInteractive children emitting fixed synthetic text and
exiting 7. No SDK or tool command is run.

For both canonical and Utilities update commands, with -ErrorAction Stop:

{"ExitCode":7,"ErrorCount":0,"Caught":null,
 "Result":{"PackageId":"example.tool","Version":null,"Updated":false}}

For both listing commands, exit 7 yields zero errors and an empty collection.
Expected: native failure must produce a meaningful PowerShell error; an update
failure must not emit the normal result as though its outcome was determined.

Acceptance criteria:

  • Check native completion explicitly for canonical discovery and update,
    independent of caller native-error preference; retain diagnostics and exit
    status in the reported error.
  • Ensure -ErrorAction Stop stops the operation, ordinary error handling remains
    usable, and failed discovery is not silently treated as known empty inventory.
  • Preserve successful result shapes, confirmation, scope, and streaming;
    Utilities wrappers must preserve the canonical errors without duplicate prompts.
  • Add harmless-native-child tests for both canonical commands and wrappers, plus
    successful empty inventory, unchanged update, and aggregate fail-fast controls.

Tracking context: #186 intentionally preserved the old implementations during
migration; this is pre-existing behavior, not a newly introduced migration
regression. Existing adapter tests explicitly detect the hidden canonical
failure. Open #259 concerns independent DSC wrappers, not these canonical
commands. No matching open canonical issue was found. The behavior may warrant
an upstream-parity issue in the bash port if that port shares this native-error
handling; the parent should check its current implementation/issue inventory.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read modules\Shmuelie.DotNet\DotNetHelpers.ps1 and its forwarding entries in modules\Shmuelie.Utilities\DotNetHelpers.ps1, then run the .NET cases in Repro-Candidates.ps1. Compare canonical, wrapper, and aggregate behavior against the acceptance criteria; done means native failures are reported and stopped, while successful result shapes and fail-fast controls remain covered by harmless-child tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli, testing-qa, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.