Repository navigation
API error handling enhancements - #21
Merged
Merged
Conversation
nicolaturcato
approved these changes
Sep 24, 2026
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.
Description
fix(client): rebuild the request body before a rate-limit retry
do() retried a 429 by calling itself with the same *http.Request, whose body the
first attempt had already consumed. The retry went out with the original
Content-Length and no data, which HTTP/2 peers reject by resetting the stream:
"stream error: stream ID n; PROTOCOL_ERROR; received from peer". Every write
carrying a body — entry and asset upserts, localized field updates — failed
whenever it hit the rate limit, which is precisely when the retry was meant to
save it.
Rebuild the body from req.GetBody(), which net/http populates for the
*bytes.Buffer bodies this client sends, and fall back to the original API error
when it is absent rather than sending an empty request.
fix(client): close the response body when there is nothing to decode
do() closed the response body on the success path only when a decode target was
given, so every call passing nil — Publish, Unpublish, Delete and nine others —
leaked its response. A publish-heavy run keeps one HTTP/2 stream open per call
until the finalizer collects it, and on HTTP/1.1 the connection cannot be
reused. Drain and close on the way out instead.
Type of Change
Related Issue
Changes
Checklist
Notes