Skip to content

Comments

feat(routing/http): return 200 for empty results per IPIP-513#1032

Merged
lidel merged 8 commits intomainfrom
feat/routing-v1-200-for-empty
Sep 16, 2025
Merged

feat(routing/http): return 200 for empty results per IPIP-513#1032
lidel merged 8 commits intomainfrom
feat/routing-v1-200-for-empty

Conversation

@lidel
Copy link
Member

@lidel lidel commented Sep 11, 2025

routing/http: Delegated Routing V1 HTTP endpoints now return 200 with empty results instead of 404 when no records are found, per IPIP-513 (#1024)

  • Server endpoints (/routing/v1/providers/{cid}, /routing/v1/peers/{peer-id}, /routing/v1/ipns/{name}) now return HTTP 200 with empty JSON arrays or appropriate content types for empty results
  • Client maintains backward compatibility by treating both 200 with empty results and 404 as "no records found"
  • Added regression tests that confirm both 200 with no results and 44 produce same results in client

TODO

  • backward compatible b35990e
  • ensure we have a prometheus metric that distinguishes between 0 results and 1+ results (i suspect we need to adjust buckets)
    • indeed, the legacy buckets were a mess due to a bug + general range discrepancy between opencensus vs prometheus. nobody sane will use them to infer "success vs total" request ratio. I've added dedicated counters for this in 3a70903

Context

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
@codecov
Copy link

codecov bot commented Sep 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.62%. Comparing base (43c1149) to head (03a9acd).
⚠️ Report is 1 commits behind head on main.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1032      +/-   ##
==========================================
+ Coverage   60.51%   60.62%   +0.11%     
==========================================
  Files         268      268              
  Lines       33399    33460      +61     
==========================================
+ Hits        20212    20286      +74     
+ Misses      11517    11507      -10     
+ Partials     1670     1667       -3     
Files with missing lines Coverage Δ
routing/http/client/client.go 74.76% <100.00%> (+3.11%) ⬆️
routing/http/client/measures.go 69.09% <100.00%> (+14.74%) ⬆️
routing/http/server/server.go 74.16% <100.00%> (-0.36%) ⬇️

... and 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

the metric now correctly reports:
- 0 for empty results (instead of 1)
- n for n results (instead of n+1)
- 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
- 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
- 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
@lidel lidel force-pushed the feat/routing-v1-200-for-empty branch from 1cff7d9 to 3a70903 Compare September 11, 2025 06:07
@lidel lidel marked this pull request as ready for review September 11, 2025 06:17
@lidel lidel merged commit 0e41866 into main Sep 16, 2025
17 checks passed
@lidel lidel deleted the feat/routing-v1-200-for-empty branch September 16, 2025 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't return 404s from routing calls Delegated routing v1 client: response status metrics

3 participants