Skip to content
Permalink
Browse files

Bug fix: Return an error when an unrecognized field exists in the res…

…olution request.
  • Loading branch information...
davemoore- committed Jul 18, 2019
1 parent 4d97d39 commit 3fdde88fea9ae0bd5058e0296d253af5c1e7cff4
Showing with 16 additions and 0 deletions.
  1. +16 −0 src/main/java/io/zentity/resolution/input/Input.java
@@ -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"))

0 comments on commit 3fdde88

Please sign in to comment.
You can’t perform that action at this time.