Skip to content

Fix confusing error message for unsupported output format; remove plain-text as advertised format#11220

Open
Copilot wants to merge 14 commits intomainfrom
copilot/fix-confusing-error-message
Open

Fix confusing error message for unsupported output format; remove plain-text as advertised format#11220
Copilot wants to merge 14 commits intomainfrom
copilot/fix-confusing-error-message

Conversation

Copy link
Contributor

Copilot AI commented Feb 11, 2026

Description

This PR improves the CLI output format handling by:

  1. Fixing the confusing error message — previously, passing an unsupported output format produced a vague error. Now it clearly tells the user which format was rejected and lists the supported formats (json, table).
  2. Removing plain-text as an advertised output formatplain-text was only accepted by rad recipe-pack show and produced output identical to table. It is no longer shown in help text or flag descriptions.
  3. Maintaining backwards compatibility — users who pass --output plain-text (e.g. in scripts) will silently get table-formatted output instead of an error.

Changes

Output format normalization

  • Added NormalizeFormat() in pkg/cli/output/formats.go that maps "plain-text""table"
  • Added FormatPlainText case in NewFormatter() that returns TableFormatter (defense in depth)

Unified validation

  • Rewrote RequireOutput() in pkg/cli/clivalidation.go to normalize "plain-text""table" before validation
  • Deleted RequireOutputAllowPlainText() and requireOutputFromFormats() — no longer needed
  • Deleted AddOutputFlagWithPlainText() from pkg/cli/cmd/commonflags/flags.go

Command updates

  • rad recipe-pack show: switched from AddOutputFlagWithPlainText + RequireOutputAllowPlainText to standard AddOutputFlag + RequireOutput
  • rad version: switched from manual flag reading to cli.RequireOutput() for consistent validation; registered output flag via commonflags.AddOutputFlag(cmd) in NewCommand()

Tests

  • Updated Test_RequireOutput: "plain-text" now expects "table" (not an error)
  • Removed Test_RequireOutputAllowPlainText (function deleted)
  • Added pkg/cli/output/formats_test.go — tests for NormalizeFormat
  • Added pkg/cli/output/formatter_test.go — tests for NewFormatter including "plain-text" case
  • Added table format test case in pkg/cli/cmd/recipepack/show/show_test.go

Backwards Compatibility

User input Before After
rad app list -o json JSON output JSON output (unchanged)
rad app list -o table Table output Table output (unchanged)
rad app list -o plain-text Error: unsupported format Table output (backwards compat)
rad app list -o text Error: unsupported format Error: unsupported format (unchanged)
rad app list --help "json, table" "json, table" (unchanged)
rad recipe-pack show X -o plain-text Table output (accepted) Table output (still accepted, normalized)
rad recipe-pack show X -o table Error: unsupported format Table output (now accepted)
rad recipe-pack show --help "plain-text, json" "json, table" (consistent)

Key point: "plain-text" was never meaningfully different from "table" — it always produced the same output. This change makes the CLI consistent while ensuring existing scripts continue to work.

Type of change

  • This pull request fixes a bug in Radius and has an approved issue (issue link required).

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

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…thout plain-text

Co-authored-by: brooke-hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix inconsistent error message for unsupported output formats Fix confusing error message for unsupported output format Feb 11, 2026
@brooke-hamilton
Copy link
Member

@copilot fix this. There should not be help text saying that plain-text is a viable output unless it is supported. Also, it doesn't make sense for one of the responses to be an error and the other response to be not an error. Both inputs should result in the same response because both inputs, text and plain-text, are invalid.

/workspace/temp/testfix $ rad app list -o text
unsupported output format "text", supported formats are: json, table, plain-text

/workspace/temp/testfix $ rad app list -o plain-text
Error: unsupported format "plain-text", supported formats are: json, table

TraceId:  dab174b39e31c7772b44b9354eb66765

…onsistent error messages

Co-authored-by: brooke-hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 11, 2026

@copilot fix this. There should not be help text saying that plain-text is a viable output unless it is supported. Also, it doesn't make sense for one of the responses to be an error and the other r...

Fixed in a924a54. RequireOutput now validates against SupportedFormats() (json, table) instead of AllFormats(), so both text and plain-text produce the same friendly error:

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

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

Added RequireOutputAllowPlainText for rad recipepack show which legitimately supports plain-text.

@brooke-hamilton
Copy link
Member

@copilot does the same fix need to be applied to other commands?

Copy link
Contributor Author

Copilot AI commented Feb 11, 2026

@copilot does the same fix need to be applied to other commands?

No, the fix already covers all commands. RequireOutput() validates against SupportedFormats() (json, table only), and every command uses RequireOutput() except rad recipepack show, which uses RequireOutputAllowPlainText() because it legitimately supports plain-text. The AddOutputFlag() help text and the root command's persistent flag also use SupportedFormats(), so no command advertises plain-text unless it actually supports it.

Copilot AI temporarily deployed to external-contributor-approval February 11, 2026 20:40 Inactive
@brooke-hamilton brooke-hamilton marked this pull request as ready for review February 11, 2026 20:40
@brooke-hamilton brooke-hamilton requested review from a team as code owners February 11, 2026 20:40
Copilot AI review requested due to automatic review settings February 13, 2026 15:46
…n, add unit tests, remove unused AllFormats

Co-authored-by: brooke-hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 17, 2026

@copilot apply changes based on the comments in this thread

Applied all three review comments in ff8d616:

  1. RequireOutputAllowPlainText now validates against []string{output.FormatPlainText, output.FormatJson} instead of output.AllFormats(), matching the AddOutputFlagWithPlainText flag help text.
  2. Added unit tests for both RequireOutput and RequireOutputAllowPlainText covering accepted formats, rejected formats, and error message content.
  3. Removed the now-unused AllFormats() function.

@github-actions
Copy link

github-actions bot commented Feb 17, 2026

Unit Tests

4 802 tests  +19   4 798 ✅ +19   7m 59s ⏱️ +12s
  330 suites ± 0       3 💤 ± 0 
    1 files   ± 0       1 ❌ ± 0 

For more details on these failures, see this check.

Results for commit 61009ac. ± Comparison against base commit a5b7a93.

♻️ This comment has been updated with latest results.

@brooke-hamilton brooke-hamilton temporarily deployed to external-contributor-approval February 19, 2026 15:43 — with GitHub Actions Inactive
@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.12%. Comparing base (9d115e2) to head (61009ac).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11220      +/-   ##
==========================================
+ Coverage   51.00%   51.12%   +0.12%     
==========================================
  Files         679      679              
  Lines       43174    43169       -5     
==========================================
+ Hits        22019    22072      +53     
+ Misses      19035    18964      -71     
- Partials     2120     2133      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

… backwards compat

- Add NormalizeFormat() in output/formats.go to map plain-text -> table
- Add plain-text case in NewFormatter() as defense in depth
- Rewrite RequireOutput() to normalize plain-text silently to table
- Delete RequireOutputAllowPlainText() and requireOutputFromFormats()
- Delete AddOutputFlagWithPlainText() from commonflags
- Switch recipe-pack show to use standard AddOutputFlag + RequireOutput
- Switch version command to use RequireOutput for consistency
- Add tests for NormalizeFormat, NewFormatter(plain-text), and updated
  RequireOutput behavior
- Add table format test case for recipe-pack show

Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
@brooke-hamilton brooke-hamilton requested a deployment to external-contributor-approval February 19, 2026 19:32 — with GitHub Actions Waiting
@brooke-hamilton brooke-hamilton changed the title Fix confusing error message for unsupported output format Fix confusing error message for unsupported output format; remove plain-text as advertised format Feb 19, 2026
Copy link
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

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Comment on lines +106 to 110
format, err := cli.RequireOutput(cmd)
if err != nil {
return err
}
if format == "" {
format = "table"
}
r.Format = format
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

The Validate method calls cli.RequireOutput() which reads the "output" flag, but this flag is never registered in the NewCommand function. The version command needs to call commonflags.AddOutputFlag(cmd) in NewCommand() to register the output flag, similar to how other commands (like recipe-pack show) do it. Without this, the command will fail at runtime with a flag not found error.

Copilot uses AI. Check for mistakes.
}
}


Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

Remove extra blank lines at the end of the file. Go convention is to have only one blank line at the end of a file.

Copilot generated this review using guidance from repository custom instructions.
@brooke-hamilton
Copy link
Member

@copilot apply changes based on the comments in this thread

…n test file

Co-authored-by: brooke-hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 19, 2026

@copilot apply changes based on the comments in this thread

Applied both changes in 6f65972:

  1. Registered the output flag in the version command via commonflags.AddOutputFlag(cmd) in NewCommand().
  2. Removed the trailing blank line in clivalidation_test.go.

Copilot AI temporarily deployed to external-contributor-approval February 19, 2026 21:17 Inactive
@brooke-hamilton brooke-hamilton temporarily deployed to external-contributor-approval February 19, 2026 21:31 — with GitHub Actions Inactive
@brooke-hamilton brooke-hamilton deployed to external-contributor-approval February 20, 2026 14:32 — with GitHub Actions Active
@radius-functional-tests
Copy link

radius-functional-tests bot commented Feb 20, 2026

Radius functional test overview

🔍 Go to test action run

Click here to see the test run details
Name Value
Repository radius-project/radius
Commit ref 3384227
Unique ID func448e45100e
Image tag pr-func448e45100e
  • 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-func448e45100e
  • 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-func448e45100e
  • dynamic-rp test image location: ghcr.io/radius-project/dev/dynamic-rp:pr-func448e45100e
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-func448e45100e
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-func448e45100e
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...

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.

2 participants

Comments