Repository navigation
Give 413 responses an actionable error - #212
Merged
Merged
Conversation
Step 4 of #6, and the last item on it. Koios enforces a request body size limit on the bulk endpoints. Exceeding it returns 413 with a plain-text body: Payload too large, body length was 18022. Please ensure your request body size is below 5120 bytes Because that is text rather than JSON, the parser added in #210 correctly leaves Result.error null, so callers got a bare status and had to know on their own that the fix is to batch. 413 now produces a KoiosError carrying the server's message verbatim plus a hint to split the request. Nothing is invented about the response itself: the status is real, so synthetic stays false, and the message is the server's own words. Only the remedy is ours, because Koios does not supply one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Step 4 of #6 — the last item on it.
Koios enforces a request body size limit on the bulk endpoints. Verified against live mainnet with 300 pool ids on
/pool_info:Two things that check corrected, both of which I had been repeating from the v1.4.2 release notes:
Because it is text, the parser added in #210 correctly leaves
Result.errornull — so a caller got a bare413and had to already know that the remedy is to batch.Change
A 413 now produces a
KoiosError:code"413"messagehintSplit the request into smaller batches and call the endpoint once per batch.Nothing about the response is invented. The status is real, so
syntheticstaysfalse, and the message is Koios's own words including its byte counts. Only the remedy is ours, because Koios does not supply one — which is precisely thehintfield's purpose.Responses that already carry a JSON error are untouched; the parsed body always wins.
Testing
Closes #6.
🤖 Generated with Claude Code