Rust: preserve structured JSON-RPC error data
Author: aurokinCreated Sep 18, 2026Updated Sep 18, 2026
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: https://github.com/github/copilot-sdk/pull/2664. This issue tracks that work; it is not a request for a duplicate implementation.
Source: github/copilot-sdk