Skip to content

Commit 3fdde88

Browse files
committed
Bug fix: Return an error when an unrecognized field exists in the resolution request.
1 parent 4d97d39 commit 3fdde88

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

  • src/main/java/io/zentity/resolution/input

src/main/java/io/zentity/resolution/input/Input.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,22 @@ public void deserialize(JsonNode json) throws ValidationException, IOException {
275275
if (!json.isObject())
276276
throw new ValidationException("Input must be an object.");
277277

278+
// Validate recognized fields.
279+
Iterator<Map.Entry<String, JsonNode>> fields = json.fields();
280+
while (fields.hasNext()) {
281+
Map.Entry<String, JsonNode> field = fields.next();
282+
String name = field.getKey();
283+
switch (name) {
284+
case "attributes":
285+
case "ids":
286+
case "model":
287+
case "scope":
288+
break;
289+
default:
290+
throw new ValidationException("'" + name + "' is not a recognized field.");
291+
}
292+
}
293+
278294
// Parse and validate the "model" field of the request body, or the entity model stored in the index.
279295
if (this.model == null) {
280296
if (this.entityType == null || !json.has("model"))

0 commit comments

Comments
 (0)