The IP lookup answers 404 "No routes found" when the database read fails #109

Closed
opened 2026-10-19 22:35:16 +02:00 by clawbot · 1 comment
Collaborator

Where: handleIPInfo in internal/server/handlers.go.

For each address, the handler calls GetIPInfoContext and on any error appends ip + ": " + err.Error() to the answer's errors list and continues, without telling database.ErrNoRoute from other errors. With one address and no results it answers 404 "No routes found: ..." (README: 404 means none of the addresses has a live route).

Scenario: GET /api/v1/ip/8.8.8.8 while the read fails for a reason other than no route (a disk I/O error, or the out-of-memory error the process-wide SQLite hard heap limit gives). The answer is 404 "No routes found: 8.8.8.8: failed to query routes: disk I/O error"; the request log records it at warn level as a 4xx. A client takes a database failure for "this address is not routed" and may cache or act on it; an operator watching 5xx counts does not see the database failing on the IP route. With two addresses, one failing and one routed, the answer is 200 with the database error listed as if the address were unrouted. handleASDetailJSON and handlePrefixDetailJSON already tell the two apart (404 for ErrNoRoute, 500 otherwise).

Severity: low.

Definition of done

  • In the loop, only database.ErrNoRoute (and ErrInvalidIP) go into errors; any other error answers 500 with the JSON error body, as the AS and prefix JSON routes do.
  • Test, failing before the fix: a store whose GetIPInfoContext returns errors.New("disk I/O error") for 192.0.2.1; GET /api/v1/ip/192.0.2.1 through the router answers 500 (today 404).
  • make check passes.

Model: fable-5-1

Where: `handleIPInfo` in `internal/server/handlers.go`. For each address, the handler calls `GetIPInfoContext` and on any error appends `ip + ": " + err.Error()` to the answer's `errors` list and continues, without telling `database.ErrNoRoute` from other errors. With one address and no results it answers 404 "No routes found: ..." (README: 404 means none of the addresses has a live route). Scenario: `GET /api/v1/ip/8.8.8.8` while the read fails for a reason other than no route (a disk I/O error, or the out-of-memory error the process-wide SQLite hard heap limit gives). The answer is 404 "No routes found: 8.8.8.8: failed to query routes: disk I/O error"; the request log records it at warn level as a 4xx. A client takes a database failure for "this address is not routed" and may cache or act on it; an operator watching 5xx counts does not see the database failing on the IP route. With two addresses, one failing and one routed, the answer is 200 with the database error listed as if the address were unrouted. `handleASDetailJSON` and `handlePrefixDetailJSON` already tell the two apart (404 for `ErrNoRoute`, 500 otherwise). Severity: low. ## Definition of done - In the loop, only `database.ErrNoRoute` (and `ErrInvalidIP`) go into `errors`; any other error answers 500 with the JSON error body, as the AS and prefix JSON routes do. - Test, failing before the fix: a store whose `GetIPInfoContext` returns `errors.New("disk I/O error")` for `192.0.2.1`; `GET /api/v1/ip/192.0.2.1` through the router answers 500 (today 404). - `make check` passes. Model: fable-5-1
clawbot self-assigned this 2026-10-19 22:35:16 +02:00
Author
Collaborator

Fixed in #133: only a missing route or an invalid address goes into errors now; any other database read error answers 500 with the JSON error body.

Model: opus-5-5

Fixed in https://git.eeqj.de/sneak/routewatch/pulls/133: only a missing route or an invalid address goes into `errors` now; any other database read error answers 500 with the JSON error body. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/routewatch#109