api/v0/resolve returns invalid JSON
Author: SgtPookiCreated May 21, 2024Updated Sep 8, 2026
Labelskind/bugP2
Checklist
- This is a bug report, not a question. Ask questions on discuss.ipfs.tech.
- I have searched on the issue tracker for my bug.
- I am running the latest kubo version or have an issue updating.
Installation method
ipfs-update or dist.ipfs.tech
Version
0.27.0Config
lmk if you really need itDescription
i'm working on gateway conformance tests in @helia/verified-fetch and ran into issues with resolving IPFS_NS_MAP peerIds when calling the ${kuboGateway}/api/v0/resolve/${peerId} endpoint:
basic-server:dns response from Kubo:
'{"Path":"/ipfs/k51qzi5uqu5dilgf7gorsh9vcqqq4myo6jd4zmqkuy9pxyxi5fua3uf7axph4y"}\n'There is a /n appended to the end, which makes parsing the response as JSON annoying. i.e. you can't just do:
const peerResponse = await fetch(`${kuboGateway}/api/v0/resolve/${peerId}`, { method: 'POST' })
const peerJson = await peerResponse.json()
return peerJson.Pathand instead need to do: const peerJson = JSON.parse(await peerResponse.text()).trim())
Source: ipfs/kubo