Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We should enforce these required inputs by returning a useful error and 400 response. right now it is 500 #780

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,20 @@ private static String getQueryString(JsonNode body) {
return queryString;
}

// This is required. consider returning a more useful error to the user than 500
// or setting a reasonable default (default seems a good option here)
private static int getHowMany(JsonNode body) {
return body.get("size").asInt();
}

// This is required. consider returning a more useful error to the user than 500
Copy link
Contributor Author

@autata autata Feb 22, 2024

Choose a reason for hiding this comment

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

probably something like this:

{
"error": {
"code": 400,
"message": "Bad Request",
"details": "The 'query.gte' field is required but missing in the request."
}
}

// or setting a reasonable default (not sure what that would be)
private static long getStartTimeEpochMs(JsonNode body) {
return body.get("query").findValue("gte").asLong();
}

// This is required. consider returning a more useful error to the user than 500
// or setting a reasonable default (not sure what that would be)
private static long getEndTimeEpochMs(JsonNode body) {
return body.get("query").findValue("lte").asLong();
}
Expand Down
Loading