Skip to content

Reduce the size of TwirpErrorResponse - #358

Merged
jorendorff merged 3 commits into
mainfrom
jorendorff/error-size
Oct 6, 2026
Merged

jorendorff merged 3 commits into
mainfrom
jorendorff/error-size

Conversation

@jorendorff

Copy link
Copy Markdown
Contributor

It's so big that Rust issues a warning when you return a Result containing it.

An easy fix is to box up all the fields. This unfortunately breaks compatibility, so we bump the version number and make all fields private, with accessors.

Copilot AI balanced review requested due to automatic review settings October 2, 2026 14:36
@jorendorff
jorendorff requested a review from a team as a code owner October 2, 2026 14:36

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

🟡 Changes recommended

Example tests still reference removed fields, and read-only message and metadata accessors are missing.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity

Open (2)
What changed in this PR

Reduces TwirpErrorResponse size by boxing its fields behind a private representation.

Changes:

  • Updates construction, serialization, formatting, and field access for the boxed representation.
  • Migrates library tests to constructors and accessors.
  • Bumps twirp to 0.12.0 and adopts Rust 2024.
File Description
crates/​twirp/​src/​error.rs Boxes error fields and updates methods and tests.
crates/​twirp/​Cargo.toml Updates the version and Rust edition.
Cargo.lock Records twirp version 0.12.0.

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

Comment thread crates/twirp/src/error.rs
Comment thread crates/twirp/src/error.rs
@jorendorff
jorendorff force-pushed the jorendorff/error-size branch from 05bcfd4 to fbb59d7 Compare October 2, 2026 17:27
It's so big that Rust issues a warning when you return a Result containing it.

An easy fix is to box up all the fields. This unfortunately breaks compatibility, so we bump the
version number and make all fields private, with accessors.
@jorendorff
jorendorff force-pushed the jorendorff/error-size branch from 8290a47 to 519e76a Compare October 2, 2026 17:30
Comment thread crates/twirp/src/error.rs Outdated
@jorendorff
jorendorff merged commit ba7c042 into main Oct 6, 2026
6 checks passed
@jorendorff
jorendorff deleted the jorendorff/error-size branch October 6, 2026 14:58
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.

3 participants