Skip to content

REST API: Return 404 for single entity endpoints with no results#551

Closed
Copilot wants to merge 1 commit intorest-single-entity-404from
copilot/sub-pr-545-another-one
Closed

REST API: Return 404 for single entity endpoints with no results#551
Copilot wants to merge 1 commit intorest-single-entity-404from
copilot/sub-pr-545-another-one

Conversation

Copy link
Copy Markdown

Copilot AI commented Jan 5, 2026

Single entity REST endpoints (e.g., /feeds/{feed_id}, /routes/{route_key}) now return HTTP 404 when the entity doesn't exist, instead of HTTP 200 with empty results. Collection endpoints continue to return HTTP 200 with empty arrays.

Changes

Handler architecture

  • Split request handlers into makeIndexHandler() (collections) and makeEntityHandler() (single entities)
  • Entity handlers check for empty responses and return 404; index handlers return 200 with empty arrays
  • Removed SingleEntity field from request structs—now determined by handler registration

Format support

  • Extended 404 behavior to all response formats: JSON, GeoJSON, GeoJSONL, PNG
  • PNG format now returns nil for empty results to enable 404 response

OpenAPI schema

  • Added 404 response definitions to all entity endpoint specifications
  • Fixed documentation typos in path templates (.format.{format})

Test coverage

  • Added assertions for 404 responses on missing entities (feeds, routes, stops, trips)
  • Added assertions for 200 responses on empty collections
  • Verified behavior across multiple formats (JSON, GeoJSON, PNG)

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI changed the title [WIP] Fix REST API to return 404 for no result on single entity endpoints REST API: Return 404 for single entity endpoints with no results Jan 5, 2026
Copilot AI requested a review from irees January 5, 2026 23:24
@irees irees closed this Jan 5, 2026
@irees irees deleted the copilot/sub-pr-545-another-one branch January 5, 2026 23:33
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.

3 participants