Skip to content

fix: passthrough gh commands when --json flag is present#325

Closed
rursache wants to merge 1 commit intortk-ai:masterfrom
rursache:fix/gh-json-passthrough
Closed

fix: passthrough gh commands when --json flag is present#325
rursache wants to merge 1 commit intortk-ai:masterfrom
rursache:fix/gh-json-passthrough

Conversation

@rursache
Copy link
Contributor

@rursache rursache commented Mar 5, 2026

Summary

  • When --json is present in args to any rtk gh subcommand (pr, issue, run, repo), passthrough directly to gh instead of applying RTK filtering
  • Previously, rtk gh pr view --json number,url would interpret --json as the PR number and then add its own --json with hardcoded fields, causing Unknown JSON field: "--json" errors
  • The check is done once at the top of run(), so it covers all gh subcommands uniformly

Fixes #313

Test plan

  • Added test_has_json_flag_present — verifies --json is detected in args
  • Added test_has_json_flag_absent — verifies no false positives
  • Added test_has_json_flag_in_pr_args — verifies detection with mixed args
  • All 519 tests pass
  • Manual test: rtk gh pr view --json number,url no longer errors

When users run `rtk gh pr view --json number,url`, RTK was interpreting
`--json` as a PR number and then adding its own `--json` with hardcoded
fields, causing "Unknown JSON field" errors.

Now detect `--json` in args early and passthrough to gh directly, since
the user explicitly wants specific JSON fields rather than RTK's filtered
output.

Fixes #313
@FlorianBruniaux
Copy link
Collaborator

Hi @jackfreem, @rursache! We have several PRs tackling gh flag passthrough (#196, #217, #319, #325, #328) — they all touch gh_cmd.rs and will conflict with each other. Before we review, can you coordinate? We're leaning toward consolidating into #328 (most complete). @jackfreem, would your --jq fix (#319) fit as an addition to #328?

@rursache
Copy link
Contributor Author

rursache commented Mar 5, 2026

Closing in favor of #328, which already includes the --json passthrough fix from this PR along with the broader -R/--repo flag passthrough. Consolidating as suggested by @FlorianBruniaux.

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.

rtk gh pr view --json ... fails

2 participants