Skip to content

Commit

Permalink
Add check for empty request and missing properties so 400s are return…
Browse files Browse the repository at this point in the history
…ed instead of NPEs/500s
  • Loading branch information
ryanrdoherty committed Jan 19, 2024
1 parent d232353 commit 04761d0
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ static AnswerRequest parseAnswerRequest(Question question,
String reporterName, JSONObject requestBody, WdkModel wdkModel, User sessionUser, boolean avoidCacheHit)
throws RequestMisformatException, DataValidationException, WdkModelException {

if (requestBody == null || !requestBody.has(JsonKeys.SEARCH_CONFIG) || !requestBody.has(JsonKeys.REPORT_CONFIG)) {
throw new RequestMisformatException("Request body must not be null and must contain '" +
JsonKeys.SEARCH_CONFIG + "' and '" + JsonKeys.REPORT_CONFIG + "' properties.");
}

// parse view filters
FilterOptionListBuilder viewFilters = AnswerSpecServiceFormat.parseViewFilters(requestBody);

Expand Down

0 comments on commit 04761d0

Please sign in to comment.