Skip to content

Commit d7505b4

Browse files
authored
Error silence (#15073)
* Error silence * PR comments * update object as well
1 parent ead062c commit d7505b4

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

airbyte-commons/src/main/java/io/airbyte/commons/json/JsonSchemas.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ private static void traverseJsonSchemaInternal(final JsonNode jsonSchemaNode,
189189
// hit every node.
190190
traverseJsonSchemaInternal(jsonSchemaNode.get(JSON_SCHEMA_ITEMS_KEY), newPath, consumer);
191191
} else {
192-
throw new IllegalArgumentException(
193-
"malformed JsonSchema array type, must have items field in " + jsonSchemaNode);
192+
log.warn("The array is missing an items field. The traversal is silently stopped. Current schema: " + jsonSchemaNode);
194193
}
195194
}
196195
case OBJECT_TYPE -> {
@@ -206,8 +205,7 @@ private static void traverseJsonSchemaInternal(final JsonNode jsonSchemaNode,
206205
traverseJsonSchemaInternal(arrayItem, path, consumer);
207206
}
208207
} else {
209-
throw new IllegalArgumentException(
210-
"malformed JsonSchema object type, must have one of the following fields: properties, oneOf, allOf, anyOf in " + jsonSchemaNode);
208+
log.warn("The object is a properties key or a combo keyword. The traversal is silently stopped. Current schema: " + jsonSchemaNode);
211209
}
212210
}
213211
}

airbyte-commons/src/test/java/io/airbyte/commons/json/JsonSchemasTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package io.airbyte.commons.json;
66

77
import static org.junit.jupiter.api.Assertions.assertEquals;
8-
import static org.junit.jupiter.api.Assertions.assertThrows;
98
import static org.mockito.Mockito.mock;
109

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

137136
@SuppressWarnings("unchecked")
138137
@Test
139-
void testTraverseArrayTypeWithNoItemsThrowsException() throws IOException {
138+
void testTraverseArrayTypeWithNoItemsDoNotThrowsException() throws IOException {
140139
final JsonNode jsonWithAllTypes = Jsons.deserialize(MoreResources.readResource("json_schemas/json_with_array_type_fields_no_items.json"));
141140
final BiConsumer<JsonNode, List<FieldNameOrList>> mock = mock(BiConsumer.class);
142141

143-
assertThrows(IllegalArgumentException.class, () -> JsonSchemas.traverseJsonSchema(jsonWithAllTypes, mock));
142+
JsonSchemas.traverseJsonSchema(jsonWithAllTypes, mock);
144143
}
145144

146145
}

0 commit comments

Comments
 (0)