Skip to content

Conversation

lidel
Copy link
Member

@lidel lidel commented Sep 11, 2025

Changes HTTP Delegated Routing V1 API to improve empty result handling:

  • servers SHOULD return 200 instead of 404 for empty results
  • clients MUST handle both 200 and 404 for backward compatibility
  • improves semantic correctness (404 means "endpoint not found", not "no data")
  • prevents browser console errors that confuse users

Follows robustness principle for maximum interoperability (strict server, liberal and robust client).

Implementations:

Copy link

github-actions bot commented Sep 11, 2025

🚀 Build Preview on IPFS ready

Changes HTTP Delegated Routing V1 API to improve empty result handling:
- servers SHOULD return 200 instead of 404 for empty results
- clients MUST handle both 200 and 404 for backward compatibility
- improves semantic correctness (404 means "endpoint not found", not "no data")
- prevents browser console errors that confuse users

Follows robustness principle for maximum interoperability.

Related to ipfs/boxo#1024
@lidel lidel force-pushed the feat/ipip-0513-routing-v1-200-for-empty branch from 291a0fc to 1d072cc Compare September 11, 2025 00:32
lidel added a commit to ipfs/boxo that referenced this pull request Sep 11, 2025
return HTTP 200 with empty results instead of 404 when no
records found, while maintaining backward compatibility
in clients to handle both response codes

Fixes: #1024
Spec: ipfs/specs#513
@aschmahmann
Copy link
Contributor

This makes sense to me. I'll just flag briefly my (perhaps incorrect) historical recollection that in Reframe these responses were 200s, and the switch to 404s with routing-v1 was partially motivated by people being annoyed they couldn't just look at error codes in grafana to see the percentage of requests that had no providers.

Seems like doing the thing that follows HTTP semantics is the thing to do though so 👍

@lidel
Copy link
Member Author

lidel commented Sep 11, 2025

@aschmahmann indeed, 404 are a lazy way of tracking "no results" that abuses HTTP semantics and creates more problems for down the stack.

These days we have way better way of tracking success rate. We have histograms of response latency and results list length, but if that is too complex, I also added simpler counter of total/success in ipfs/boxo#1032.

It shows you don't need 404 for visibility into this.

@lidel lidel marked this pull request as ready for review September 11, 2025 06:19
@lidel lidel requested a review from a team as a code owner September 11, 2025 06:19
@lidel lidel changed the title IPIP-0513: Delegated Routing V1 returns 200 for empty results IPIP-513: Delegated Routing V1 returns 200 for empty results Sep 15, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in IPIP pipeline Sep 15, 2025
@lidel lidel moved this from Needs Triage to 🔍 Ready for Final Reviews in IPIP pipeline Sep 15, 2025
lidel added a commit to ipfs/boxo that referenced this pull request Sep 16, 2025
* feat: implement IPIP-513 for routing v1 endpoints

return HTTP 200 with empty results instead of 404 when no
records found, while maintaining backward compatibility
in clients to handle both response codes

Fixes: #1024
Spec: ipfs/specs#513

* docs: add IPIP-513 changes to changelog

* fix: correct off-by-one error in routing_http_client_length metric

the metric now correctly reports:
- 0 for empty results (instead of 1)
- n for n results (instead of n+1)

* feat: add metrics for IPNS operations

- GetIPNS now records latency, status code, and length (0 or 1)
- PutIPNS now records latency and status code
- uses consistent pattern with httpReq.Host for host extraction

* docs: explain histogram bucket interpretation for metrics

- document how OpenCensus bucket selection works (value < boundary)
- explain mapping to Prometheus le buckets for both latency and length
- provide examples of how to extract meaningful data from metrics

* feat: add simple counter metrics for requests and positive responses

- routing_http_client_requests_total: counts all requests including errors
- routing_http_client_positive_responses_total: counts requests with 1+ results
- avoids confusing histogram bucket math for common queries
- documented with simple Grafana query examples

* fix: drain response body for connection reuse in 404 cases

ensure http connection can be reused by draining response body before closing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🔍 Ready for Final Reviews
Development

Successfully merging this pull request may close these issues.

2 participants