Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api/v0/resolve returns invalid JSON #10428

Open
3 tasks done
SgtPooki opened this issue May 21, 2024 · 0 comments
Open
3 tasks done

api/v0/resolve returns invalid JSON #10428

SgtPooki opened this issue May 21, 2024 · 0 comments
Labels
kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization

Comments

@SgtPooki
Copy link
Member

SgtPooki commented May 21, 2024

Checklist

Installation method

ipfs-update or dist.ipfs.tech

Version

0.27.0

Config

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())

@SgtPooki SgtPooki added kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization labels May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization
Projects
No open projects
Status: No status
Development

No branches or pull requests

1 participant