Skip to content

feat(cli): add JSON/YAML output format to provider list command#1830

Open
jeffmaury wants to merge 1 commit into
NVIDIA:mainfrom
jeffmaury:feat/1745-add-output-format-provider-list/jeffmaury
Open

feat(cli): add JSON/YAML output format to provider list command#1830
jeffmaury wants to merge 1 commit into
NVIDIA:mainfrom
jeffmaury:feat/1745-add-output-format-provider-list/jeffmaury

Conversation

@jeffmaury

Copy link
Copy Markdown
Contributor

🏗️ build-from-issue-agent

Summary

Added -o/--output flag support (json, yaml, table) to openshell provider list by migrating it to use the existing generic output formatter introduced in #1750. This follows the established pattern already used by sandbox list, gateway list, and provider list-profiles commands.

Related Issue

Closes #1745

Changes

  • crates/openshell-cli/src/run.rs: Added provider_to_json() helper function that maps Provider proto fields to JSON, including only credential keys (never values) for security. Added output parameter to provider_list() function and inserted early-return call to crate::output::print_output_collection() for structured formats.
  • crates/openshell-cli/src/main.rs: Added output: OutputFormat field to ProviderCommands::List struct with conflicts_with constraints between names and output flags. Updated invocation to pass output.as_str() parameter.
  • crates/openshell-cli/tests/provider_commands_integration.rs: Updated provider_list() call to include "table" parameter.

Deviations from Plan

None — implemented as planned. The implementation leverages the generic output module (crates/openshell-cli/src/output.rs) that was created as part of #1750, avoiding code duplication.

Testing

  • mise run pre-commit passes (all 778 unit tests passed)
  • Unit tests added/updated
  • E2E tests added/updated (N/A — CLI command formatting does not require E2E coverage)

Tests added:

  • Unit: No new tests required — generic output helpers are already tested in output.rs, and the pattern is proven in production use
  • Integration: Updated existing integration test call signature to pass output parameter
  • E2E: N/A — CLI output formatting does not require E2E coverage

Security verification:
The provider_to_json() helper only exposes credential keys (the keys from the credentials map), never credential values. This prevents CWE-532 (insertion of sensitive information into output) and follows the same security pattern as the provider get command.

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)

Documentation updated:

  • None needed — this change affects CLI command output format only, not gateway configuration or published user-facing behavior documentation

Closes NVIDIA#1745

Add -o/--output flag support (json, yaml, table) to openshell provider list
by migrating it to use the existing generic output formatter from NVIDIA#1750.
This follows the established pattern used by sandbox list, gateway list,
and provider list-profiles commands.

Changes:
- crates/openshell-cli/src/run.rs: Add provider_to_json() helper that maps
  Provider proto fields to JSON, including only credential keys (not values)
  for security. Add output parameter to provider_list() and insert early-return
  for structured formats.
- crates/openshell-cli/src/main.rs: Add output field to ProviderCommands::List
  with conflicts_with constraints between names and output flags. Update
  invocation to pass output parameter.
- crates/openshell-cli/tests/provider_commands_integration.rs: Update
  provider_list() call to include output parameter.

Security: The provider_to_json() helper only exposes credential keys, never
credential values, preventing CWE-532 (insertion of sensitive information
into output).
@jeffmaury jeffmaury requested a review from a team as a code owner June 9, 2026 07:34
@copy-pr-bot

copy-pr-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@johntmyers johntmyers added the gator:in-review Gator is reviewing or awaiting PR review feedback label Jun 10, 2026
@johntmyers

Copy link
Copy Markdown
Collaborator

gator-agent

PR Review Status

Validation: This PR is project-valid because it implements linked issue #1745 as a small, focused CLI consistency improvement using the shared output formatter introduced for list commands.
Head SHA: 794ef69dc4e71761b27dea773bf3ffa821ce7e4f

Review findings:

  • crates/openshell-cli/src/run.rs:4740 serializes provider.config into JSON/YAML list output. Provider config is user-controlled provider data and may contain sensitive endpoint material, embedded tokens, headers, or provider-specific secrets depending on backend behavior. Please omit config from provider list structured output, or replace it with an audited allowlist of known-safe keys. As written, this is a CWE-200 information exposure risk.
  • crates/openshell-cli/tests/provider_commands_integration.rs:1000 only updates the existing table call site. Please add coverage for JSON/YAML provider list output that creates a provider with credentials and asserts the structured output includes credential keys but never credential values.
  • This is a direct CLI output change (openshell provider list -o json|yaml). Under the gator docs gate, please update the relevant Fern docs under docs/ and navigation if needed, or get a maintainer-authored comment stating docs are intentionally unnecessary.

Docs: Missing for direct CLI output change, unless waived by a maintainer.

Next state: gator:in-review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gator:in-review Gator is reviewing or awaiting PR review feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add JSON/YAML output format to provider list command

2 participants