Skip to content

getProviders returns empty array if delegated routing server returns Content-Type header that is not "application/json" exactly #154

@Rinse12

Description

@Rinse12

What's the problem

Delegated routing client is too rigid with its expectation of Content-Type header value. In this line:
https://github.com/ipfs/helia-delegated-routing-v1-http-api/blob/main/packages/client/src/client.ts#L142

If the value is not "application/json", then it will return an empty array for getProviders, with no error logs or anything. Even if the status was 200.

We have a routing server that returns Content-Type="application/json; charset=utf-8", and clients are not able to consume its providers JSON.

Reproduction

  const client = createDelegatedRoutingV1HttpApiClient("https://peers.pleb.bot");
  

   const generator = client.getProviders(CID.parse("QmdjSj3KGquq2hucok1F7fNRmvi9DhZidh9NsRpdk3Q553"), {
    filterAddrs: undefined,
    filterProtocols: undefined,
  });
  
  const firstValue = await generator.next(); // undefined, even though the routing server responds with at least one provider

  // No errors at all as well

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium: Good to have, but can wait until someone steps updif/easySomeone with a little familiarity can pick upeffort/hoursEstimated to take one or several hoursgood first issueGood issue for new contributorshelp wantedSeeking public contribution on this issuekind/bugA bug in existing code (including security flaws)status/readyReady to be worked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions