Skip to content

Commit

Permalink
Bug fix: Return an error when an unrecognized field exists in the res…
Browse files Browse the repository at this point in the history
…olution request.
  • Loading branch information
davemoore- committed Jul 18, 2019
1 parent 4d97d39 commit 3fdde88
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/java/io/zentity/resolution/input/Input.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,22 @@ public void deserialize(JsonNode json) throws ValidationException, IOException {
if (!json.isObject())
throw new ValidationException("Input must be an object.");

// Validate recognized fields.
Iterator<Map.Entry<String, JsonNode>> fields = json.fields();
while (fields.hasNext()) {
Map.Entry<String, JsonNode> field = fields.next();
String name = field.getKey();
switch (name) {
case "attributes":
case "ids":
case "model":
case "scope":
break;
default:
throw new ValidationException("'" + name + "' is not a recognized field.");
}
}

// Parse and validate the "model" field of the request body, or the entity model stored in the index.
if (this.model == null) {
if (this.entityType == null || !json.has("model"))
Expand Down

0 comments on commit 3fdde88

Please sign in to comment.