Fix IPFS cat decoding for ipfs-http-client 56 (Uint8Array) #251

Merged
raucao merged 1 commits from fix/ipfs-uint8array-decode into master 2026-10-29 16:10:08 +00:00
Owner

Problem

ipfs-http-client 56 yields Uint8Array chunks, but IPFS#cat() concatenates them with buffer.toString(). For a Uint8Array, toString() returns comma-separated byte values instead of text, so every document became an invalid JSON string, e.g. {"@context":... turned into 123,10,32,32,34,64,99,111,110,....

JSON.parse then failed with Unexpected non-whitespace character after JSON at position 3 (line 1 column 4), and no IPFS-backed record could be read. This surfaced in hubot-kredits as SyntaxError from contributor.js deserialize() on every pull_request closed hook, so no contributions were proposed anymore. It affects any Node consumer reading through the IPFS HTTP API (hubot-kredits integrations, scripts/review-kredits.js); kredits-web was unaffected because it reads via gatewayUrl.

The bug was introduced when ipfs-http-client was bumped from ^41 (Buffer chunks) to ^56 (Uint8Array chunks) in 53fafc1.

Fix

Decode the chunks explicitly with a streaming TextDecoder, which works in both Node and browsers. Bump version to 7.5.1 so consumers can depend on the fix.

Verification

Against the live stack (RSK testnet 10.1.1.20:4444, IPFS 10.1.1.198:5001), reading contributor records:

  • Before: cat() returned "123,10,32,32,34,64,99,..." and JSON.parse threw the error above.
  • After: all 21 contributors deserialize and findByAccount({ site: 'github.com', username: 'silverbucket' }) resolves correctly.

Note: this needs a new npm release (7.5.1); hubot-kredits will then be bumped to depend on it.

## Problem `ipfs-http-client` 56 yields `Uint8Array` chunks, but `IPFS#cat()` concatenates them with `buffer.toString()`. For a `Uint8Array`, `toString()` returns comma-separated byte values instead of text, so every document became an invalid JSON string, e.g. `{"@context":...` turned into `123,10,32,32,34,64,99,111,110,...`. `JSON.parse` then failed with `Unexpected non-whitespace character after JSON at position 3 (line 1 column 4)`, and no IPFS-backed record could be read. This surfaced in hubot-kredits as `SyntaxError` from `contributor.js` `deserialize()` on every `pull_request closed` hook, so no contributions were proposed anymore. It affects any Node consumer reading through the IPFS HTTP API (hubot-kredits integrations, `scripts/review-kredits.js`); `kredits-web` was unaffected because it reads via `gatewayUrl`. The bug was introduced when `ipfs-http-client` was bumped from `^41` (Buffer chunks) to `^56` (Uint8Array chunks) in 53fafc1. ## Fix Decode the chunks explicitly with a streaming `TextDecoder`, which works in both Node and browsers. Bump version to 7.5.1 so consumers can depend on the fix. ## Verification Against the live stack (RSK testnet `10.1.1.20:4444`, IPFS `10.1.1.198:5001`), reading contributor records: - Before: `cat()` returned `"123,10,32,32,34,64,99,..."` and `JSON.parse` threw the error above. - After: all 21 contributors deserialize and `findByAccount({ site: 'github.com', username: 'silverbucket' })` resolves correctly. Note: this needs a new npm release (7.5.1); hubot-kredits will then be bumped to depend on it.
raucao added 1 commit 2026-10-29 16:02:57 +00:00
Fix IPFS cat decoding for ipfs-http-client 56 (Uint8Array)
Release Drafter / Update release notes draft (pull_request) Failing after 3s
f24e9a8a0b
ipfs-http-client 56 yields Uint8Array chunks, whose toString() returns
comma-separated byte values rather than text. Concatenating those turned
every document into an invalid JSON string ("123,10,32,..."), so
JSON.parse failed with "Unexpected non-whitespace character after JSON at
position 3" and no IPFS-backed record could be read.

Decode the chunks explicitly with a streaming TextDecoder, which works in
both Node and browsers. Bump version to 7.5.1.
raucao added the bugkredits-1 labels 2026-10-29 16:10:03 +00:00
raucao merged commit e18c06742f into master 2026-10-29 16:10:08 +00:00
raucao deleted branch fix/ipfs-uint8array-decode 2026-10-29 16:10:09 +00:00
Sign in to join this conversation.