DSC icon indicating copy to clipboard operation
DSC copied to clipboard

Listing adapted resources results in ERROR_NOT_SUPPORTED

Open JohnMcPMS opened this issue 7 months ago • 2 comments

Prerequisites

  • [x] Write a descriptive title.
  • [x] Make sure you are able to repro it on the latest version
  • [x] Search the existing issues.

Summary

More generally, the rust Command::spawn call can potentially error like:

WARN Command: Operation The request is not supported. (os error 50) for executable 'pwsh'

I do not have a 100% repro, but there are situations in which I have had a fairly reliable (~90%) repro. All of these repro states occur when winget's configuration server is invoking dsc.exe AND the server has package identity. Attaching a debugger to dsc.exe prevents the repro. All of these things point to a race of some kind, but despite my efforts I have not been able to identify it.

This issue only started occurring at scale when I added the ability to get adapted resource information via calls like:

dsc.exe resource list -a Microsoft.DSC/PowerShell Microsoft.Windows.Developer/DeveloperMode

I can currently repro this frequently IFF the configuration server is running elevated; in the same workflow it works when the server is not elevated.

Steps to reproduce

With the document:

# dev-mode-v3.yaml
# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.3
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/config/document.json
metadata:
  winget:
    processor:
      identifier: "dscv3"
resources:
- name: Microsoft.Windows.Developer/DeveloperMode_w64qq6qo
  type: Microsoft.Windows.Developer/DeveloperMode
  metadata:
    description: "Configure Microsoft.Windows.Developer/DeveloperMode"
    securityContext: elevated
  properties:
    Ensure: 1
    IsEnabled: true

and the latest winget preview package (I have v1.11.280-preview, but we haven't actually published the first build with the required change yet 😓), run:

> winget configure dev-mode-v3.yaml

The following steps are relevant:

  1. winget creates an unelevated server (A)
  2. the unelevated server (A) runs dsc.exe resource list -a Microsoft.DSC/PowerShell Microsoft.Windows.Developer/DeveloperMode and it succeeds
  3. winget creates an elevated server (B)
  4. the elevated server (B) runs the same dsc command, but most of the time it fails with the stated error

Expected behavior

dsc can create child processes

Actual behavior

dsc sometimes cannot create child processes

Error details


Environment data

Name                           Value
----                           -----
PSVersion                      7.5.1
PSEdition                      Core
GitCommitId                    7.5.1
OS                             Microsoft Windows 10.0.26411
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

dsc 3.1.0-preview.4

Visuals

No response

JohnMcPMS avatar May 07 '25 23:05 JohnMcPMS

dsc 3.1.0-preview.5 did not resolve the issue.

JohnMcPMS avatar May 08 '25 17:05 JohnMcPMS

On more investigation, the issue only affects listing adapted resources. I made the flow ignore that as an error and when it attempts to use the resource things work just fine.

JohnMcPMS avatar May 08 '25 22:05 JohnMcPMS