Skip to content

Preserve structured JSON-RPC error data - #2664

Open
ellismg wants to merge 2 commits into
mainfrom
ellismg-preserve-rpc-error-data-a1c
Open

ellismg wants to merge 2 commits into
mainfrom
ellismg-preserve-rpc-error-data-a1c

Conversation

@ellismg

@ellismg ellismg commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • preserve optional structured JSON-RPC error data on copilot::Error
  • expose non-null object, array, and scalar data through Error::rpc_data(); omitted and null data return None
  • preserve existing RPC error kind, numeric code, message, Display/Debug formatting, and source behavior; payload access stays explicit
  • add framed JSON-RPC regressions for payload shapes, omitted/null data, and formatting compatibility

Fixes #2726

Follow-up validation

The Debug compatibility assertion failed before the correction (RED) and passed afterward (GREEN). The focused client_call_ selection passes all 3 tests; the affected error selection passes all 6 tests with backtraces enabled.

Commands run from rust/:

COPILOT_SKIP_CLI_DOWNLOAD=1 cargo test --no-default-features --features test-support --test prepared_session_test client_call_
COPILOT_SKIP_CLI_DOWNLOAD=1 RUST_BACKTRACE=1 cargo test --no-default-features --features test-support --test prepared_session_test error
COPILOT_SKIP_CLI_DOWNLOAD=1 cargo check --no-default-features --features test-support --lib --test prepared_session_test
rustup run nightly-2026-04-14 rustfmt --check --config-path .rustfmt.nightly.toml --config skip_children=true src/errors.rs src/lib.rs tests/prepared_session_test.rs

git diff --check also passed. The framed tests use in-memory transport, with runtime downloads disabled. The existing validate_runtime_pair dead-code warning in that configuration is unchanged. No full local suite or Clippy rerun was needed for the follow-up.

Original author-reported validation

  • cargo test --all-features --test prepared_session_test client_call_
  • rustup run nightly-2026-04-14 cargo fmt --check
  • cargo clippy --all-features --all-targets -- -D warnings
  • cargo test --all-features

Keep JSON-RPC error data on copilot::Error and expose it through rpc_data() while retaining existing code, message, display, and source behavior. Add framed transport regressions for responses with and without data.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep structured data accessible through rpc_data without changing formatted error output. Cover non-object payloads and distinguish omitted data from explicit null in framed RPC tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@aurokin

aurokin commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Updated the Rust error-data change to preserve existing Debug formatting. Structured data remains available through Error::rpc_data(), with focused framed-protocol coverage for JSON values and omitted/null data. Follow-up validation is recorded in the PR description.

@aurokin
aurokin marked this pull request as ready for review September 18, 2026 20:09
@aurokin
aurokin requested a review from a team as a code owner September 18, 2026 20:09
Copilot AI balanced review requested due to automatic review settings September 18, 2026 20:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The implementation meets the stated contract with focused regression coverage and no unresolved issues.

Review effort: Balanced
Findings: None

What changed in this PR

Preserves structured JSON-RPC error payloads in the Rust SDK while maintaining existing error behavior.

Changes:

  • Adds explicit Error::rpc_data() access.
  • Retains payloads during RPC error conversion.
  • Covers payload shapes, null handling, and formatting compatibility.
File Description
rust/​tests/​prepared_session_test.rs Adds framed RPC error regression tests.
rust/​src/​lib.rs Preserves data during RPC error conversion.
rust/​src/​errors.rs Stores and exposes optional RPC data.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rust: preserve structured JSON-RPC error data

3 participants