Skip to content

agent: Fix a UTF-8 boundary panic in the agent streaming parser (#58432) (cherry-pick to stable)#58452

Merged
zed-zippy[bot] merged 1 commit into
v1.5.xfrom
cherry-pick-v1.5.x-19b7625a
Jun 3, 2026
Merged

agent: Fix a UTF-8 boundary panic in the agent streaming parser (#58432) (cherry-pick to stable)#58452
zed-zippy[bot] merged 1 commit into
v1.5.xfrom
cherry-pick-v1.5.x-19b7625a

Conversation

@zed-zippy

@zed-zippy zed-zippy Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Cherry-pick of #58432 to stable


The parser stores emitted byte offsets between partial tool-call parses.
Because partial JSON can be repaired differently as more bytes arrive, a
byte offset that was valid in an earlier string can land inside a
multibyte character in a later string. We now normalize those offsets
with find_char_boundary before slicing.

Added property tests covering boundary-sensitive write/edit streaming
sequences to prevent regressions.

Fixes Sentry ZED-8Y1 / 7523469866.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX
    checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • Fixed a crash that could occur while streaming agent edits containing
    multibyte characters.

The parser stores emitted byte offsets between partial tool-call parses.
Because partial JSON can be repaired differently as more bytes arrive, a
byte offset that was valid in an earlier string can land inside a
multibyte character in a later string. We now normalize those offsets
with `find_char_boundary` before slicing.

Added property tests covering boundary-sensitive write/edit streaming
sequences to prevent regressions.

Fixes Sentry ZED-8Y1 / 7523469866.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed a crash that could occur while streaming agent edits containing
multibyte characters.
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 3, 2026
@zed-community-bot zed-community-bot Bot added the bot Pull requests authored by a bot label Jun 3, 2026
@zed-zippy zed-zippy Bot merged commit 6bdae69 into v1.5.x Jun 3, 2026
41 checks passed
@zed-zippy zed-zippy Bot deleted the cherry-pick-v1.5.x-19b7625a branch June 3, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot Pull requests authored by a bot cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant