Skip to content

fix: measure redacted file content with lone surrogates - #893

Open
bandzalkin wants to merge 1 commit into
mainfrom
fix/redact-lone-surrogates-INT-1887
Open

bandzalkin wants to merge 1 commit into
mainfrom
fix/redact-lone-surrogates-INT-1887

Conversation

@bandzalkin

Copy link
Copy Markdown
Contributor

Why

redact_tool_call_args measures band_send_room_file content with len(content.encode("utf-8")). A lone surrogate in that string (half of a UTF-16 pair, a byte-ish blob decoded leniently) makes the encode raise UnicodeEncodeError inside the redactor, so the whole tool_call event is lost instead of being redacted.

What

Measure with errors="surrogatepass" so the placeholder is computed for any str. The regression test fails on main with UnicodeEncodeError and passes with the fix.

Scope

One shared runtime function; no adapter behavior changes beyond the event now being emitted. Carved out of #763.

A lone surrogate in band_send_room_file's content made the redactor's
byte count raise UnicodeEncodeError, dropping the whole tool_call event.
Encode with surrogatepass so the placeholder is measured and emitted.
@linear-code

linear-code Bot commented Oct 21, 2026

Copy link
Copy Markdown

INT-1887

bandzalkin added a commit to bandzalkin/band-sdk-python that referenced this pull request Oct 21, 2026
bandzalkin added a commit to bandzalkin/band-sdk-python that referenced this pull request Oct 21, 2026
github-actions Bot pushed a commit to bandzalkin/band-sdk-python that referenced this pull request Oct 21, 2026
github-actions Bot pushed a commit to bandzalkin/band-sdk-python that referenced this pull request Oct 21, 2026
github-actions Bot pushed a commit to bandzalkin/band-sdk-python that referenced this pull request Oct 21, 2026
@bandzalkin
bandzalkin marked this pull request as ready for review October 22, 2026 01:54
github-actions Bot pushed a commit to bandzalkin/band-sdk-python that referenced this pull request Oct 22, 2026

This branch has not been deployed

No deployments
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