Skip to content

REST API: for single entity endpoints, return a 404 when no result#545

Merged
irees merged 6 commits intomainfrom
rest-single-entity-404
Jan 5, 2026
Merged

REST API: for single entity endpoints, return a 404 when no result#545
irees merged 6 commits intomainfrom
rest-single-entity-404

Conversation

@drewda
Copy link
Copy Markdown
Member

@drewda drewda commented Dec 28, 2025

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)

Copilot AI review requested due to automatic review settings December 28, 2025 14:51

This comment was marked as outdated.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 31, 2025

Generated Code Check ✅

All generated code is up to date.

This comment was marked as outdated.

@irees
Copy link
Copy Markdown
Contributor

irees commented Jan 5, 2026

@copilot regenerate review

This comment was marked as outdated.

@irees
Copy link
Copy Markdown
Contributor

irees commented Jan 5, 2026

@copilot can you provide an updated summary of all the changes in this PR, replacing the old summary you wrote originally

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@irees
Copy link
Copy Markdown
Contributor

irees commented Jan 5, 2026

@copilot summarize changes in this PR as a comment. DO NOT create a new issue or PR.

Copy link
Copy Markdown

Copilot AI commented Jan 5, 2026

@irees I've opened a new pull request, #551, to work on those changes. Once the pull request is ready, I'll request review from you.

@irees irees merged commit b188b32 into main Jan 5, 2026
18 checks passed
@irees irees deleted the rest-single-entity-404 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.

4 participants