PowerShell / PowerShell/DSC

Malformed JSON output for `dsc resource get --all`

Open
#729 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Bug Need-Review
Dominant language
Rust
Stars
523
Forks
75
Avg merge
3d 16h
Merged PRs (30d)
24

Description

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

The output for the dsc resource get command with the --all option emits a series of JSON objects without a wrapping array. For both the compressed (default, JSON Line) and pretty JSON output formats, the command emits each object directly after the last. It doesn't include a newline between objects, and the items aren't wrapped in an array.

This makes the output view difficult to parse and prevents users from leveraging tools like jq or the ConvertFrom-Json cmdlet.

Steps to reproduce
  1. Build DSC.

  2. Invoke the following commands:

    # Output to terminal
    dsc resource get Microsoft/Process --all --output-format pretty-json
    # Convert streaming results
    dsc resource get Microsoft/Process --all --output-format pretty-json | ConvertFrom-Json
    
Expected behavior
dsc resource get Microsoft/Process --all --output-format pretty-json

[
  {
    "actualState": {
      "pid": 4136,
      "name": "\"svchost.exe\"",
      "cmdline": "[]"
    }
  },
  {
    "actualState": {
      "pid": 22860,
      "name": "\"RuntimeBroker.exe\"",
      "cmdline": "[]"
    }
  }
]
Actual behavior
dsc resource get Microsoft/Process --all --output-format pretty-json

{
  "actualState": {
    "pid": 4136,
    "name": "\"svchost.exe\"",
    "cmdline": "[]"
  }
}{
  "actualState": {
    "pid": 22860,
    "name": "\"RuntimeBroker.exe\"",
    "cmdline": "[]"
  }
}
Error details

Environment data
Name                           Value
----                           -----
PSVersion                      7.5.0
PSEdition                      Core
GitCommitId                    7.5.0
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Version

Build from main

Visuals

No response

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 by reproducing dsc resource get Microsoft/Process --all with both pretty-json and the default compressed output, then trace the dsc resource get output handling. Done means each format emits valid JSON with all results wrapped in an array and separated correctly so jq and ConvertFrom-Json can parse it.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.