rtk-ai/rtk

bug(rtk curl): JSON schema conversion destroys API response values, breaks browser CDP connections

Open

#1152 opened on Apr 10, 2026

View on GitHub
 (5 comments) (0 reactions) (0 assignees)Rust (48,085 stars) (2,914 forks)batch import
bugeffort-mediumfilter-qualitygood first issueresolved-pending-close

Description

Problem

When rtk curl receives JSON output, it runs it through json_cmd::filter_json_string() which converts JSON values to their types (schema mode). This destroys actual data values that AI agents and scripts need to read.

Real-world impact: AI browser tool breakage

When an AI agent runs curl -s http://localhost:9222/json/version to get the Chrome DevTools Protocol WebSocket URL, Chrome returns:

```json { "webSocketDebuggerUrl": "ws://127.0.0.1:9222/devtools/browser/abc-123", "browser": "Chrome/131.0.0.0" } ```

RTK converts this to a schema:

``` { webSocketDebuggerUrl: string, browser: string } ```

The actual WebSocket URL is destroyed. The browser tool cannot connect because it never receives the URL value.

Root cause

`src/cmds/cloud/curl_cmd.rs` lines 58-67:

```rust if (trimmed.starts_with('{') || trimmed.starts_with('[')) && (trimmed.ends_with('}') || trimmed.ends_with(']')) { if let Ok(schema) = json_cmd::filter_json_string(trimmed, 5) { // Only use schema if it is actually shorter than the original if schema.len() <= trimmed.len() { return schema; // SCHEMA replaces actual values! } } } ```

This behavior is correct for reducing tokens when showing an API structure to an LLM, but wrong for commands where values matter (CDP endpoints, auth tokens, IDs, URLs).

Proposed fix

  1. Add a --raw / --no-filter flag to rtk curl that skips JSON schema conversion and returns raw output
  2. Skip schema conversion for localhost/127.0.0.1 URLs -- these are typically internal API responses where values are needed
  3. Default to keeping original JSON when it is already compact (the current length check helps but still converts if schema is shorter, even if the original was small and readable)

Relevant code

  • `src/cmds/cloud/curl_cmd.rs` (lines 54-88: `filter_curl_output`)
  • `src/cmds/system/json_cmd.rs` (schema conversion logic)

Workaround

Users can currently add `curl` to `exclude_commands` in `~/.config/rtk/config.toml` or use `rtk proxy curl ` instead of `rtk curl `.

Affected files

  • `src/cmds/cloud/curl_cmd.rs`
  • `src/cmds/system/json_cmd.rs`
  • `src/discover/rules.rs` (curl rewrite rule, line 216)

Contributor guide