Repository navigation
Conversation
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the Contributor License Agreement (CLA) and hereby sign the CLA. |
imharjot
force-pushed
the
fix-fetch-utf8-truncation
branch
from
October 22, 2026 05:45
a592f25 to
58bbed1
Compare
Author
|
Rebased onto 17fccc0, keeping the newer fetch network-error and HTTP-status tests alongside the UTF-8 regressions. The complete race-enabled suite (63 test packages), build and CI-pinned golangci-lint v2.13.1 all pass locally. The CLA check also passed. The new build, security and lint workflows require maintainer approval; could someone approve those fork runs so the remote matrix can check this head? |
imharjot
force-pushed
the
fix-fetch-utf8-truncation
branch
from
November 3, 2026 07:49
58bbed1 to
4eeedcd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fetching a large UTF-8 page can fail with
Response content is not valid UTF-8when the byte limit lands inside a character. For example, 102399 ASCII bytes followed by界trigger the error even though the response is valid UTF-8. Formatting the response as Markdown can also split a character at the output limit.Read a small, bounded lookahead to validate the character at the boundary, then keep a complete UTF-8 prefix. This fixes both
fetchand sub-agentweb_fetchwhile preserving errors for malformed input. The existing truncation notice now reflects whether the response was actually cut, including when HTML extraction makes the result shorter; a complete response exactly at the limit no longer gets a notice.Added 12 local HTTP regression cases covering two-, three-, and four-byte characters, Markdown output, exact limits, and malformed input. Kept upstream’s refreshed cassette and updated two recorded requests to include the truncation notices for the plain-text and HTML fetch results. The recorded responses were preserved and replayed locally.
Validation on macOS with Go 1.27.0, rebased onto
3b1f8604f0027cf5fa47f29a27655ef1aeed8d8f(head4eeedcdd2a7230d380370ab76299a3bf5af230c1):go test -race ./internal/agent/tools -run TestFetch -count=1and the DeepSeek fetch cassette replay passed.go mod tidyleft the module files unchanged andgo build -race ./...passed. The fullgo test -race -failfast ./...rerun passed. The first run reported a race in the unchanged Docker MCP backend test; it did not reproduce in five targeted or six full backend-package runs on upstream.git diff --checkpassed.The rebase preserves the newer upstream fetch error handling and its tests. No dependency, workflow or unrelated source changes are included. GitHub Actions results are separate from these local checks.