Skip to content

Fix JSON output for rad app graph command#11207

Merged
brooke-hamilton merged 4 commits intoradius-project:mainfrom
nellshamrell:app-graph-json-fix
Feb 11, 2026
Merged

Fix JSON output for rad app graph command#11207
brooke-hamilton merged 4 commits intoradius-project:mainfrom
nellshamrell:app-graph-json-fix

Conversation

@nellshamrell
Copy link
Copy Markdown
Contributor

@nellshamrell nellshamrell commented Feb 9, 2026

Allows rad app graph command to output json

(Please note I am very new to Go development and welcome feedback on things I can improve!)

Description

Fixes bug where rad app graph -o json was not outputting json.

Type of change

Fixes: #11205

Contributor checklist

Please verify that the PR meets the following requirements, where applicable:

  • An overview of proposed schema changes is included in a linked GitHub issue.
    • Yes
    • Not applicable
  • A design document PR is created in the design-notes repository, if new APIs are being introduced.
    • Yes
    • Not applicable
  • The design document has been reviewed and approved by Radius maintainers/approvers.
    • Yes
    • Not applicable
  • A PR for the samples repository is created, if existing samples are affected by the changes in this PR.
    • Yes
    • Not applicable
  • A PR for the documentation repository is created, if the changes in this PR affect the documentation or any user facing updates are made.
    • Yes
    • Not applicable
  • A PR for the recipes repository is created, if existing recipes are affected by the changes in this PR.
    • Yes
    • Not applicable

Allows rad app graph command to output json

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enables rad app graph to honor -o json by adding the shared output flag and emitting structured output for JSON format, aligning the command with other CLI commands that support --output.

Changes:

  • Add --output/-o support to rad app graph and plumb the selected format into the runner.
  • When -o json is selected, write the raw ApplicationGraphResponse via WriteFormatted.
  • Add a unit test covering JSON output behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/cli/cmd/app/graph/graph.go Adds output flag support and JSON formatted output path for rad app graph.
pkg/cli/cmd/app/graph/graph_test.go Adds a new test ensuring JSON format uses WriteFormatted.

Comment on lines +98 to +103
format, err := cli.RequireOutput(cmd)
if err != nil {
return err
}
r.Format = format

Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output format read from the flag is never validated/normalized. If a user passes an unsupported value (or a different casing like -o JSON), Run() will silently fall back to the table-style display instead of returning an error / emitting JSON. Normalize the flag value (trim/lowercase) and validate it against output.SupportedFormats() (or use output.NewFormatter for validation) during Validate(), then switch on the normalized value in Run().

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Copy link
Copy Markdown
Member

@brooke-hamilton brooke-hamilton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one nit: please update the PR title to something descriptive like "Fix JSON output for rad app graph command"

The rad app graph -o json command works well:

$ rad app graph --output json | jq
{
  "resources": [
    {
      "connections": [],
      "id": "/planes/radius/local/resourcegroups/default/providers/Applications.Core/containers/demo",
      "name": "demo",
      "outputResources": [
        {
          "id": "/planes/kubernetes/local/namespaces/default-testfix/providers/apps/Deployment/demo",
          "name": "demo",
          "type": "apps/Deployment"
        },
        {
          "id": "/planes/kubernetes/local/namespaces/default-testfix/providers/core/Service/demo",
          "name": "demo",
          "type": "core/Service"
        },
        {
          "id": "/planes/kubernetes/local/namespaces/default-testfix/providers/core/ServiceAccount/demo",
          "name": "demo",
          "type": "core/ServiceAccount"
        },
        {
          "id": "/planes/kubernetes/local/namespaces/default-testfix/providers/rbac.authorization.k8s.io/Role/demo",
          "name": "demo",
          "type": "rbac.authorization.k8s.io/Role"
        },
        {
          "id": "/planes/kubernetes/local/namespaces/default-testfix/providers/rbac.authorization.k8s.io/RoleBinding/demo",
          "name": "demo",
          "type": "rbac.authorization.k8s.io/RoleBinding"
        }
      ],
      "provisioningState": "Succeeded",
      "type": "Applications.Core/containers"
    }
  ]
}

return err
}
r.Format = format

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to what Copilot said: the format command falls back to text when the output is invalid. Other commands validate the input. Here's an example:

# This command fails silently.
$ rad app graph --output banana
Displaying application: testfix

Name: demo (Applications.Core/containers)
Connections: (none)
Resources:
  demo (apps/Deployment)
  demo (core/Service)
  demo (core/ServiceAccount)
  demo (rbac.authorization.k8s.io/Role)
  demo (rbac.authorization.k8s.io/RoleBinding)

# This command fails as expected.
$ rad app list --output banana
Error: unsupported format banana

TraceId:  a44b8eb4a8f8aa693d96b8ffae79d59f

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ rad app graph -o banana
unsupported output format "banana", supported formats are: json, table, plain-text

@nellshamrell nellshamrell changed the title Fixes #11205 Fix JSON output for rad app graph command Feb 10, 2026
@nellshamrell
Copy link
Copy Markdown
Contributor Author

@copilot open a new pull request to apply changes based on the comments in this thread

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
@nellshamrell nellshamrell temporarily deployed to external-contributor-approval February 11, 2026 00:23 — with GitHub Actions Inactive
Copy link
Copy Markdown
Member

@brooke-hamilton brooke-hamilton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@nellshamrell nellshamrell temporarily deployed to external-contributor-approval February 11, 2026 16:56 — with GitHub Actions Inactive
@radius-functional-tests
Copy link
Copy Markdown

radius-functional-tests bot commented Feb 11, 2026

Radius functional test overview

🔍 Go to test action run

Click here to see the test run details
Name Value
Repository nellshamrell/radius
Commit ref 313affc
Unique ID funceea31b1714
Image tag pr-funceea31b1714
  • gotestsum 1.13.0
  • KinD: v0.29.0
  • Dapr: 1.14.4
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-funceea31b1714
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-funceea31b1714
  • dynamic-rp test image location: ghcr.io/radius-project/dev/dynamic-rp:pr-funceea31b1714
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-funceea31b1714
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-funceea31b1714
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting corerp-cloud functional tests...
⌛ Starting ucp-cloud functional tests...
✅ ucp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded

@brooke-hamilton brooke-hamilton merged commit 1dbbb57 into radius-project:main Feb 11, 2026
50 checks passed
sk593 pushed a commit that referenced this pull request Feb 13, 2026
Allows rad app graph command to output json

(Please note I am very new to Go development and welcome feedback on
things I can improve!)

# Description

Fixes bug where `rad app graph -o json` was not outputting json.

## Type of change

<!--

Please select **one** of the following options that describes your
change and delete the others. Clearly identifying the type of change you
are making will help us review your PR faster, and is used in authoring
release notes.

If you are making a bug fix or functionality change to Radius and do not
have an associated issue link please create one now.

-->
- This pull request fixes a bug in Radius and has an approved issue
(issue link required). (Not necessarily approved, but I filed issue
#11205 before filing this pull request)


<!--

Please update the following to link the associated issue. This is
required for some kinds of changes (see above).

-->

Fixes: #11205 

## Contributor checklist
Please verify that the PR meets the following requirements, where
applicable:

<!--
This checklist uses "TaskRadio" comments to make certain options
mutually exclusive.
See:
https://github.com/mheap/require-checklist-action?tab=readme-ov-file#radio-groups
For details on how this works and why it's required.
-->

- An overview of proposed schema changes is included in a linked GitHub
issue.
    - [ ] Yes <!-- TaskRadio schema -->
    - [x] Not applicable <!-- TaskRadio schema -->
- A design document PR is created in the [design-notes
repository](https://github.com/radius-project/design-notes/), if new
APIs are being introduced.
    - [ ] Yes <!-- TaskRadio design-pr -->
    - [x] Not applicable <!-- TaskRadio design-pr -->
- The design document has been reviewed and approved by Radius
maintainers/approvers.
    - [ ] Yes <!-- TaskRadio design-review -->
    - [x] Not applicable <!-- TaskRadio design-review -->
- A PR for the [samples
repository](https://github.com/radius-project/samples) is created, if
existing samples are affected by the changes in this PR.
    - [ ] Yes <!-- TaskRadio samples-pr -->
    - [x] Not applicable <!-- TaskRadio samples-pr -->
- A PR for the [documentation
repository](https://github.com/radius-project/docs) is created, if the
changes in this PR affect the documentation or any user facing updates
are made.
    - [ ] Yes <!-- TaskRadio docs-pr -->
    - [x] Not applicable <!-- TaskRadio docs-pr -->
- A PR for the [recipes
repository](https://github.com/radius-project/recipes) is created, if
existing recipes are affected by the changes in this PR.
    - [ ] Yes <!-- TaskRadio recipes-pr -->
    - [x] Not applicable <!-- TaskRadio recipes-pr -->

---------

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Co-authored-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
willtsai pushed a commit that referenced this pull request Mar 30, 2026
Allows rad app graph command to output json

(Please note I am very new to Go development and welcome feedback on
things I can improve!)

# Description

Fixes bug where `rad app graph -o json` was not outputting json.

## Type of change

<!--

Please select **one** of the following options that describes your
change and delete the others. Clearly identifying the type of change you
are making will help us review your PR faster, and is used in authoring
release notes.

If you are making a bug fix or functionality change to Radius and do not
have an associated issue link please create one now.

-->
- This pull request fixes a bug in Radius and has an approved issue
(issue link required). (Not necessarily approved, but I filed issue
#11205 before filing this pull request)

<!--

Please update the following to link the associated issue. This is
required for some kinds of changes (see above).

-->

Fixes: #11205

## Contributor checklist
Please verify that the PR meets the following requirements, where
applicable:

<!--
This checklist uses "TaskRadio" comments to make certain options
mutually exclusive.
See:
https://github.com/mheap/require-checklist-action?tab=readme-ov-file#radio-groups
For details on how this works and why it's required.
-->

- An overview of proposed schema changes is included in a linked GitHub
issue.
    - [ ] Yes <!-- TaskRadio schema -->
    - [x] Not applicable <!-- TaskRadio schema -->
- A design document PR is created in the [design-notes
repository](https://github.com/radius-project/design-notes/), if new
APIs are being introduced.
    - [ ] Yes <!-- TaskRadio design-pr -->
    - [x] Not applicable <!-- TaskRadio design-pr -->
- The design document has been reviewed and approved by Radius
maintainers/approvers.
    - [ ] Yes <!-- TaskRadio design-review -->
    - [x] Not applicable <!-- TaskRadio design-review -->
- A PR for the [samples
repository](https://github.com/radius-project/samples) is created, if
existing samples are affected by the changes in this PR.
    - [ ] Yes <!-- TaskRadio samples-pr -->
    - [x] Not applicable <!-- TaskRadio samples-pr -->
- A PR for the [documentation
repository](https://github.com/radius-project/docs) is created, if the
changes in this PR affect the documentation or any user facing updates
are made.
    - [ ] Yes <!-- TaskRadio docs-pr -->
    - [x] Not applicable <!-- TaskRadio docs-pr -->
- A PR for the [recipes
repository](https://github.com/radius-project/recipes) is created, if
existing recipes are affected by the changes in this PR.
    - [ ] Yes <!-- TaskRadio recipes-pr -->
    - [x] Not applicable <!-- TaskRadio recipes-pr -->

---------

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Co-authored-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Signed-off-by: Will Tsai <28876888+willtsai@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rad app graph -o json is not outputting json

3 participants