microsoft / microsoft/winget-cli

Configuration COM API always provides an input to dsc, even when none is specified

Open
#5,746 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Bug
Dominant language
C++
Stars
26.4k
Forks
1.8k
Avg merge
1d 11h
Merged PRs (30d)
15

Description

Relevant area(s)

COM API

Relevant command(s)

No response

Brief description of your issue

When using the COM API to run dsc resource get, it always passes an --input to the DSC command. Some resources, like Microsoft.WinGet/UserSettingsFile, don’t actually expect any input for the Get method. But since input is provided anyway, DSC tries to validate it against the schema, which in this case requires the settings property. To get around this, I just include an empty settings object in the input to satisfy the validation.

Source: https://github.com/microsoft/winget-cli/blob/ab887ef34b306133599442d6a70ff0ac50f2768a/src/Microsoft.Management.Configuration.Processor/DSCv3/Schema_2024_04/DSCv3.cs#L113

Steps to reproduce
ConfigurationStaticFunctions config = new();
var processor = await CreateConfigurationProcessorAsync(DSCv3);
var input = config.CreateConfigurationUnit();
input.Type = "Microsoft.WinGet/UserSettingsFile";
var result = await Task.Run(() => processor.GetUnitSettings(input));
Expected behavior

If you're using the COM API and don't have an input for a unit, just leave out the --input flag when running the dsc command.

Actual behavior

Even when no input is actually given, the --input flag is still included by default.

Environment
N/A

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

Start at the COM API path using ConfigurationStaticFunctions, CreateConfigurationProcessorAsync, and GetUnitSettings, then trace how the dsc command arguments are assembled. Compare the reproduced unit with the expected behavior and verify that --input is omitted when no input is provided.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.