ipfs / ipfs/kubo

api/v0/resolve returns invalid JSON

Open
#10,428 1 comment 0 reactions 1 assignee Claimed by @gammazero View on GitHub
kind/bug P2
Dominant language
Go
Stars
17.1k
Forks
3.2k
Avg merge
3d 18h
Merged PRs (30d)
11

Description

### Checklist

- [X] This is a bug report, not a question. Ask questions on [discuss.ipfs.tech](https://discuss.ipfs.tech/c/help/13).
- [X] I have searched on the [issue tracker](https://github.com/ipfs/kubo/issues?q=is%3Aissue) for my bug.
- [X] I am running the latest [kubo version](https://dist.ipfs.tech/#kubo) or have an issue updating.

### Installation method

ipfs-update or dist.ipfs.tech

### Version

```Text
0.27.0
```

### Config

```json
lmk if you really need it
```

### Description

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.Path
```

and instead need to do: `const peerJson = JSON.parse(await peerResponse.text()).trim())`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.