Skip to content

Commit

Permalink
Error silence (#15073)
Browse files Browse the repository at this point in the history
* Error silence

* PR comments

* update object as well
  • Loading branch information
benmoriceau committed Jul 27, 2022
1 parent ead062c commit d7505b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ private static void traverseJsonSchemaInternal(final JsonNode jsonSchemaNode,
// hit every node.
traverseJsonSchemaInternal(jsonSchemaNode.get(JSON_SCHEMA_ITEMS_KEY), newPath, consumer);
} else {
throw new IllegalArgumentException(
"malformed JsonSchema array type, must have items field in " + jsonSchemaNode);
log.warn("The array is missing an items field. The traversal is silently stopped. Current schema: " + jsonSchemaNode);
}
}
case OBJECT_TYPE -> {
Expand All @@ -206,8 +205,7 @@ private static void traverseJsonSchemaInternal(final JsonNode jsonSchemaNode,
traverseJsonSchemaInternal(arrayItem, path, consumer);
}
} else {
throw new IllegalArgumentException(
"malformed JsonSchema object type, must have one of the following fields: properties, oneOf, allOf, anyOf in " + jsonSchemaNode);
log.warn("The object is a properties key or a combo keyword. The traversal is silently stopped. Current schema: " + jsonSchemaNode);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package io.airbyte.commons.json;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;

import com.fasterxml.jackson.databind.JsonNode;
Expand Down Expand Up @@ -136,11 +135,11 @@ void testTraverseMultiTypeComposite() throws IOException {

@SuppressWarnings("unchecked")
@Test
void testTraverseArrayTypeWithNoItemsThrowsException() throws IOException {
void testTraverseArrayTypeWithNoItemsDoNotThrowsException() throws IOException {
final JsonNode jsonWithAllTypes = Jsons.deserialize(MoreResources.readResource("json_schemas/json_with_array_type_fields_no_items.json"));
final BiConsumer<JsonNode, List<FieldNameOrList>> mock = mock(BiConsumer.class);

assertThrows(IllegalArgumentException.class, () -> JsonSchemas.traverseJsonSchema(jsonWithAllTypes, mock));
JsonSchemas.traverseJsonSchema(jsonWithAllTypes, mock);
}

}

0 comments on commit d7505b4

Please sign in to comment.