Created by Copilot.
Description
When a POST request is made to /validate with an incorrect field name (e.g. url instead of feedUrl), or with a missing feedUrl field entirely, the API returns a 500 Internal Server Error instead of a meaningful 400 Bad Request.
Steps to reproduce
curl -X POST https://gbfs.api.mobilitydatabase.org/validate \
-H "Content-Type: application/json" \
-d '{"url":"https://gbfs.velobixi.com/gbfs/gbfs.json"}'
Expected behavior
{ "status": 400, "error": "Bad Request", "message": "feedUrl is required" }
Actual behavior
{ "status": 500, "error": "Internal Server Error", "path": "/validate" }
Root cause
In ValidateApiDelegateHandler.validatePost(), getFeedUrl() returns null when the field is absent or misnamed. This null is passed directly to loader.load(), which throws an uncaught exception that Spring converts to a 500.
Suggested fix
Add a null/blank check at the top of validatePost():
if (validatePostRequest.getFeedUrl() == null || validatePostRequest.getFeedUrl().isBlank()) {
return ResponseEntity.badRequest().build();
}
Or preferably, annotate feedUrl with @NotBlank in ValidatePostRequest and add @Valid to the controller parameter — Spring will then return a 400 automatically with a descriptive message.
Created by Copilot.
Description
When a POST request is made to
/validatewith an incorrect field name (e.g.urlinstead offeedUrl), or with a missingfeedUrlfield entirely, the API returns a500 Internal Server Errorinstead of a meaningful400 Bad Request.Steps to reproduce
Expected behavior
{ "status": 400, "error": "Bad Request", "message": "feedUrl is required" }Actual behavior
{ "status": 500, "error": "Internal Server Error", "path": "/validate" }Root cause
In
ValidateApiDelegateHandler.validatePost(),getFeedUrl()returnsnullwhen the field is absent or misnamed. This null is passed directly toloader.load(), which throws an uncaught exception that Spring converts to a 500.Suggested fix
Add a null/blank check at the top of
validatePost():Or preferably, annotate
feedUrlwith@NotBlankinValidatePostRequestand add@Validto the controller parameter — Spring will then return a 400 automatically with a descriptive message.