Skip to content

Format Rust StatusError payloads via StatusPayloadPrinter with ByteStr-style escaping and a 512-byte limit. - #2261

Draft
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_1002724673
Draft

copybara-service[bot] wants to merge 1 commit into
masterfrom
test_1002724673

Conversation

@copybara-service

Copy link
Copy Markdown

Format Rust StatusError payloads via StatusPayloadPrinter with ByteStr-style escaping and a 512-byte limit.

Previously, StatusError Display/Debug output rendered non-UTF-8 payloads with {bytes:02x?}, turning binary proto payloads such as util.MessageSetPayload into long bracketed hex lists ([0b, 10, 86, ...]) of unbounded size, and ignored any registered C++ absl::status_internal::StatusPayloadPrinter.

Now each payload is:

  1. Formatted by the registered C++ StatusPayloadPrinter when it recognizes the payload, matching C++ StatusRep::ToString().
  2. Otherwise escaped like Debug for ByteStr: printable ASCII and valid UTF-8 pass through, while control characters and invalid UTF-8 are escaped (\n, \xff, ...).
  3. Truncated to 512 bytes, followed by ....

…yteStr`-style escaping and a 512-byte limit.

Previously, `StatusError` `Display`/`Debug` output rendered non-UTF-8 payloads with `{bytes:02x?}`, turning binary proto payloads such as `util.MessageSetPayload` into long bracketed hex lists (`[0b, 10, 86, ...]`) of unbounded size, and ignored any registered C++ `absl::status_internal::StatusPayloadPrinter`.

Now each payload is:
1. Formatted by the registered C++ `StatusPayloadPrinter` when it recognizes the payload, matching C++ `StatusRep::ToString()`.
2. Otherwise escaped like `Debug` for `ByteStr`: printable ASCII and valid UTF-8 pass through, while control characters and invalid UTF-8 are escaped (`\n`, `\xff`, ...).
3. Truncated to 512 bytes, followed by `...`.

PiperOrigin-RevId: 1002724673
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.

1 participant