fix :- return 404 when no stops match prefix query in search-stop - #1426
fix :- return 404 when no stops match prefix query in search-stop#1426Aaravanand00 wants to merge 4 commits into
Conversation
Resolves pending 404 behavior mentioned in OneBusAway#1162. - search_stops_handler: Returns 404 Not Found if FTS query returns 0 stops. - search_stops_handler_test: Updates TestSearchStopsHandlerNoResults to expect 404.
|
Aaravanand seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe stop search handler now returns HTTP 404 when no stops match. Tests verify the HTTP status and error response code for empty and non-matching queries. ChangesStop search not-found behavior
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to Stop searches with no database matches now return the standard 404 response, with tests covering empty and non-matching results. No current merge-blocking risk remains. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
omlahore
left a comment
There was a problem hiding this comment.
I think the pre-filter rule only lands on one of the two paths that can return zero matches. sanitizeFTS5Query strips the input before the query is built, so input=" " or input='*()"' or input="!!!" all bail out at the len(terms) == 0 return further up with a 200 and an empty list, and never reach the new check.
On the RABA fixture that gives "NonExistentStopName12345" a 404 but "!!!" a 200, and both of those matched nothing before any filtering. I am not sure whether #1162 means unparseable input to be its own case, but if it does I guess it is worth a line in the test so the split is deliberate rather than just where the early return happens to sit.



This PR completes the remaining spec parity requirements for the
/api/where/search/stop.jsonendpoint mentioned in #1162.Changes included :-
internal/restapi/search_stops_handler.go: Updated the handler to properly return an HTTP404 Not Foundresponse if the database query returns 0 stops (pre-filter empty state). Previously, it fell through to return200 OKwith an empty list.internal/restapi/search_stops_handler_test.go: Updated theTestSearchStopsHandlerNoResultstest to asserthttp.StatusNotFoundinstead ofhttp.StatusOK, aligning the test with the actual required spec behavior.Note: All other requirements from #1162 (such as route-type exclusions,
includeReferences, exact-boundarylimitExceeded, parent station resolution, and sorting) are already covered by existing tests merged in previous PRs (like #1164 and #1284).Fixes #1162
Summary by CodeRabbit