Raise API response body cap from 1 MiB to 16 MiB#1228
Merged
Conversation
`entire activity` requests up to a month of commits from
`/api/v1/me/commits` and routinely receives 1.5+ MiB JSON responses.
The 1 MiB cap in `api.DecodeJSON` silently truncated the body mid-JSON
via `io.LimitReader`, leaving `json.Unmarshal` to surface
fetch activity: decode commits: decode JSON response: unexpected end of JSON input
— which looked like a server bug but was self-inflicted truncation.
Raise the cap to 16 MiB. Still a defensive cap against unbounded reads,
but accommodates the activity endpoint's real payload size with
headroom for active users.
Add a regression test that exercises a ~2 MiB body and would fail under
the old 1 MiB cap with the exact error users hit.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 85adbe5f263b
Contributor
There was a problem hiding this comment.
Pull request overview
Raises the API response body size cap from 1 MiB to 16 MiB to fix entire activity failures caused by silent truncation of large JSON responses from /api/v1/me/commits.
Changes:
- Increase
maxResponseBytesconstant from1 << 20to16 << 20. - Add regression test
TestDecodeJSONResponse_LargeBodyOverOldCapexercising a ~1.9 MiB JSON payload.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cmd/entire/cli/api/client.go | Bumps response body read cap to 16 MiB. |
| cmd/entire/cli/api/client_test.go | Adds regression test verifying decoding of bodies above the old 1 MiB cap. |
pjbgf
approved these changes
May 19, 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.
https://entire.io/gh/entireio/cli/trails/394
Summary
entire activityfails for any active user with:Root cause:
/api/v1/me/commits?timeframe=last-month&limit=1000returns ~1.5 MB of valid JSON for an active account, butapi.DecodeJSONcaps reads atmaxResponseBytes = 1 << 20(1 MiB) viaio.LimitReader. The body is silently truncated mid-JSON, andjson.Unmarshalthen surfaces "unexpected end of JSON input" — which looks like a server bug but is self-inflicted.Reproduction against production:
1.46 MB > 1 MiB cap → truncated → invalid JSON → error.
Fix
Raise the global cap from 1 MiB to 16 MiB (
cmd/entire/cli/api/client.go:15). Still a defensive cap against unbounded reads, but gives the activity endpoint real headroom for active users.Test
New regression test
TestDecodeJSONResponse_LargeBodyOverOldCap(cmd/entire/cli/api/client_test.go):httptest.ServerDecodeJSONdecodes the full structureVerified the test catches the regression: reverting
maxResponseBytesto1 << 20makes the test fail with the exact user-facing error:Verification
mise run check(fmt + lint + unit + integration + E2E canary) — all greenNote
Low Risk
Low risk: only increases a defensive read limit for API responses, with a regression test to catch truncation; main impact is higher potential memory use when decoding very large responses.
Overview
Fixes CLI failures when API endpoints return JSON bodies larger than 1 MiB by increasing the shared
maxResponseBytescap to 16 MiB for bothDecodeJSONandCheckResponsereads.Adds a regression test that serves and successfully decodes a ~2 MiB JSON payload to ensure large-but-valid responses no longer get truncated mid-JSON.
Reviewed by Cursor Bugbot for commit 0b9fa0a. Configure here.