Skip to content

bug(json): curl filter outputs invalid JSON — object keys lose double quotes #1015

Closed

Description

@pszymkowiak

Description

When rtk curl filters JSON API responses, the output has unquoted object keys, producing invalid JSON that breaks downstream parsers (python3 -c 'json.load(...)', jq, etc.).

Reproduction

# With rtk:
rtk curl -s https://any-api.example/endpoint | python3 -c 'import sys,json; json.load(sys.stdin)'
# => JSONDecodeError: Expecting property name enclosed in double quotes

# Without rtk (works fine):
rtk proxy curl -s https://any-api.example/endpoint | python3 -c 'import sys,json; json.load(sys.stdin)'
# => OK

Expected vs Actual

Expected (valid JSON):

{"id": 123, "status": "open"}

Actual (invalid — keys unquoted):

{id: 123, status: "open"}

Root Cause

In src/cmds/system/json_cmd.rs, the extract_schema() function formats object keys without wrapping them in double quotes:

// Lines 251-258
lines.push(format!("{}  {}: {},", indent, key, val_trimmed));  // missing quotes around key
lines.push(format!("{}  {}: {}", indent, key, val_trimmed));   // missing quotes around key
lines.push(format!("{}  {}:", indent, key));                   // missing quotes around key

This is called from curl_cmd.rs line 61 via filter_json_string() → extract_schema().

Impact

  • Any pipeline that does rtk curl ... | python3 -c 'json.load(...)' or | jq . breaks
  • Workaround: rtk proxy curl bypasses filtering but defeats the purpose of rtk
  • Affects all JSON API calls through curl (Gitea, GitHub, REST APIs, etc.)

Environment

  • rtk v0.34.3 (stable) and dev-0.35.0-rc.108 — both affected
  • macOS ARM64

Fix

Wrap key in double quotes at lines 253, 255, and 258 of json_cmd.rs.

Activity

  1. added
    bug
    effort-small
    filter-quality
    good first issue
    on Apr 4, 2026
  2. pszymkowiak commented on Apr 4, 2026

    @pszymkowiak
    CollaboratorAuthor

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 97%

    Summary

    JSON output from rtk curl produces invalid JSON with unquoted object keys; fix is identified and a PR (#1023) is already in progress.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/cmds/system/json_cmd.rs
    • src/cmds/system/curl_cmd.rs

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  3. added 3 commits that reference this issue on Apr 4, 2026
    df70cea
    01d8927
    52a9b8c
  4. KuSh commented on Nov 23, 2026

    @KuSh
    Collaborator

    rtk curl no longer rewrites JSON responses into a schema view: PR #1310 removed that conversion in v0.37.2, and PR #1602 (v0.39.0) passes JSON bodies through unchanged. A nested JSON response through rtk curl -s now comes out byte-identical to curl's own output and parses with json.load, piped or in a terminal. If you still get unquoted keys on the latest release, please comment or reopen with the command you ran.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clibugeffort-smallfilter-qualitygood first issueplatform:macospriority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions