question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[workload] Machine readable outputs should only output JSON

See original GitHub issue

Is your feature request related to a problem? Please describe.

Commands like dotnet workload update --print-rollback and dotnet workload list --machine-readable are very helpful, but they should print only JSON to stdout.

Right now I run dotnet workload list --machine-readable and this is what gets printed to stdout:

Failed to update the advertising manifest microsoft.net.sdk.tvos: Unable to load the service index for source https://REDACTED/index.json..
Failed to update the advertising manifest microsoft.net.sdk.android: Unable to load the service index for source https://REDACTED/index.json..
Failed to update the advertising manifest microsoft.net.sdk.maui: Unable to load the service index for source https://REDACTED/index.json..
Failed to update the advertising manifest microsoft.net.workload.emscripten: Unable to load the service index for source https://REDACTED/index.json..
Failed to update the advertising manifest microsoft.net.sdk.macos: Unable to load the service index for source https://REDACTED/index.json..
Failed to update the advertising manifest microsoft.net.sdk.maccatalyst: Unable to load the service index for source https://REDACTED/index.json..
Failed to update the advertising manifest microsoft.net.sdk.ios: Unable to load the service index for source https://REDACTED/index.json..
Failed to update the advertising manifest microsoft.net.workload.mono.toolchain: Unable to load the service index for source https://REDACTED/index.json..
==workloadListJsonOutputStart==
{"installed":["macos","ios"],"updateAvailable":[{"existingManifestVersion":"12.0.101-preview.10.249","availableUpdateManifestVersion":"12.0.101-preview.10.251","description":".NET SDK Workload for building macOS applications.","workloadId":"macos"},{"existingManifestVersion":"15.0.101-preview.9.31","availableUpdateManifestVersion":"15.0.101-preview.10.251","description":".NET SDK Workload for building iOS applications.","workloadId":"ios"}]}
==workloadListJsonOutputEnd==

I have to process this and it complicates my tooling.

Describe the solution you’d like

Commands like rg, lsblk, losetup, etc that offer JSON output modes only print JSON to stdout. Everything else goes to stderr. dotnet workload commands that are intended to offer machine-readable output would be most useful if they functioned similarly.

This opens up much easier shell scripting workflows. In powershell you could pipe to ConvertFrom-Json without any other ceremony. In other shells you could pipe to jq.

Additional context

I would imagine this would break compatibility with tools used to the current output, so unfortunately it would require another option, like --really-machine-readable.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
sandyarmstrongcommented, Mar 18, 2022

We likely wouldn’t need those if that output were hidden by default (and would only include the indicators when verbosity level is high).

Could also just output the manifest errors and other verbose items to stderr instead of stdout.

0reactions
baronfelcommented, Jul 20, 2022

Summary for anyone that picks this up:

  • We should emit the verbose “failed to …” output to stderr
  • We should remove the boundary markers
Read more comments on GitHub >

github_iconTop Results From Across the Web

Machine-Readable Status — FoundationDB 7.1
This command will output status information in JSON (rather than the human-readable format output by status and status details ). See the status...
Read more >
⚙ D96883 Add support for JSON output style to ...
This patch adds JSON output style to llvm-symbolizer to better support CLI automation by providing a machine readable output.
Read more >
Output Data - Amazon SageMaker
The value of the label can be any valid JSON. In this case the label's value is the index of the class in...
Read more >
Internals: JSON Output Format | Terraform
Terraform provides a machine-readable JSON representation of state, configuration and plan.
Read more >
Events in JSON format - Workload Security - Trend Cloud One™
When published to Amazon SNS, events are sent in the SNS Message as an array of JSON objects that are encoded as strings....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found