Skip to content

fix(curl): preserve valid JSON output for piping (#1015)#1016

Open
pszymkowiak wants to merge 1 commit intodevelopfrom
fix/json-keys-quotes
Open

fix(curl): preserve valid JSON output for piping (#1015)#1016
pszymkowiak wants to merge 1 commit intodevelopfrom
fix/json-keys-quotes

Conversation

@pszymkowiak
Copy link
Copy Markdown
Collaborator

Summary

Problem

rtk curl https://api.example/endpoint | python3 -c 'json.load(sys.stdin)' failed because:

  1. extract_schema() replaced values with type names (int, string, bool)
  2. Object keys were unquoted ({name: string} instead of {"name": "string"})

Fix

  • curl_cmd: JSON responses pass through unchanged (no schema transform)
  • json_cmd: keys are now double-quoted in extract_schema() for other consumers
  • Non-JSON output still gets truncated as before

Test plan

  • cargo test curl_cmd — 4 tests pass
  • cargo test json_cmd — 9 tests pass
  • Manual: rtk curl <api> | python3 -c 'json.load(...)' works

curl filter was converting JSON values to type names (extract_schema),
producing invalid output that broke downstream JSON parsers (python, jq).

Changes:
- curl_cmd: pass JSON through unchanged instead of schema transform
- json_cmd: quote object keys in extract_schema for valid JSON output
- Added tests for JSON validity and quoted keys
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.

1 participant