Skip to content

Rust: preserve structured JSON-RPC error data #2726

Description

@aurokin

Problem

The Rust SDK converts incoming JSON-RPC errors into copilot::Error without exposing the optional error.data payload. Callers can read the numeric code and message but cannot inspect structured error details without parsing human-readable text.

Reproduction

Return a framed JSON-RPC error for a client call, for example:

{
  "jsonrpc": "2.0",
  "id": "1",
  "error": {
    "code": -32600,
    "message": "The request was rejected",
    "data": {
      "code": "request_blocked",
      "setting": "example_setting"
    }
  }
}

The resulting Rust error should make the structured payload available to the caller.

Expected behavior

  • Expose retained data through Error::rpc_data() -> Option<&serde_json::Value> for callers using the shared RPC conversion path.
  • Preserve non-null JSON objects, arrays, and scalar values; omitted or null data should return None.
  • Preserve existing RPC error kind, numeric code, message, display/debug formatting, and source behavior. Reading data should be explicit, not an automatic addition to formatted logs.

Related work

Existing implementation PR: #2664. This issue tracks that work; it is not a request for a duplicate implementation.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions