You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The cache's store method is not atomic. It is protected by a mutex, but this mutex only prevents concurrent in-process writes. If multiple invocations of the gh CLI are run in parallel then two concurrent writes to the same cache file can occur, corrupting the cache.
Similarly if a process dies mid-write then a partially written file can end up in the cache.
A simple fix for this would be to make the cache write atomic by writing to a temporary file and then doing an atomic move to overwrite the cache entry.
I just hit this issue with gh 2.97.0 on macOS while running:
gh pr merge <number> --squash --delete-branch
The command failed consistently with:
invalid character 'd' after object key
With GH_DEBUG=api, the failure occurred while reading the cached PullRequest_fields GraphQL introspection response. The cached body was visibly corrupted and contained a duplicated/interleaved JSON prefix:
{"data":{"PullReque{"data":{"PullRequest":...
The request completed in about 800 µs and returned an older Date header, confirming that it was served from the local cache rather than the network.
Clearing the cache fixed it immediately:
gh config clear-cache
After that, the same gh pr merge command completed normally. This looks like a concrete instance of the non-atomic cache write described here.
Activity
hyrious commentedon Aug 7, 2026
I just hit this issue with
gh 2.97.0on macOS while running:The command failed consistently with:
With
GH_DEBUG=api, the failure occurred while reading the cachedPullRequest_fieldsGraphQL introspection response. The cached body was visibly corrupted and contained a duplicated/interleaved JSON prefix:The request completed in about 800 µs and returned an older
Dateheader, confirming that it was served from the local cache rather than the network.Clearing the cache fixed it immediately:
After that, the same
gh pr mergecommand completed normally. This looks like a concrete instance of the non-atomic cache write described here.fix(api): make HTTP response cache writes atomic