Skip to content

khive-request: raw control-char parse error should teach the escape syntax and MCP double-escape #491

Description

@ohdearquant

Problem

A raw newline byte inside a quoted string in the function-call DSL fails with the serde-level message:

MCP -32602: control character ( -) found while parsing a string

The error is technically correct and the grammar is fine (ADR-016 string escapes follow JSON and already ship), but the message teaches nothing. Worse, the natural fix a caller tries — writing \n in the JSON tool argument — still fails, because the MCP transport decodes that to a literal newline byte before the DSL parser runs. The working form from an MCP client is the double escape \\n. Nobody discovers this unaided; users have repeatedly landed on the wrong "must switch to the JSON op form" workaround instead.

Fix

When string decoding fails on a control character, return an error that:

  1. names the offending character and its position,
  2. states that string escapes follow JSON (\n, \t, \", \\),
  3. notes that callers passing ops through a JSON transport (every MCP client) must double-escape (\\n in the wire form).

Grammar unchanged — this is error-message-only. Normative basis: ADR-084 §3c (PR #490). Parser tolerance for raw control chars was considered and rejected there (Alternatives §6).

Where

crates/khive-requestparse_value hands the quoted slice to serde_json::from_str; wrap that error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions