diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/CollectionConfig.java b/src/main/java/io/weaviate/client6/v1/api/collections/CollectionConfig.java index 8381623be..70448ce6a 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/CollectionConfig.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/CollectionConfig.java @@ -264,16 +264,19 @@ public void write(JsonWriter out, CollectionConfig value) throws IOException { public CollectionConfig read(JsonReader in) throws IOException { var jsonObject = JsonParser.parseReader(in).getAsJsonObject(); - var mixedProperties = jsonObject.get("properties").getAsJsonArray(); var references = new JsonArray(); var properties = new JsonArray(); - for (var property : mixedProperties) { - var dataTypes = property.getAsJsonObject().get("dataType").getAsJsonArray(); - if (dataTypes.size() == 1 && DataType.KNOWN_TYPES.contains(dataTypes.get(0).getAsString())) { - properties.add(property); - } else { - references.add(property); + if (jsonObject.has("properties") && jsonObject.get("properties").isJsonArray()) { + var mixedProperties = jsonObject.get("properties").getAsJsonArray(); + + for (var property : mixedProperties) { + var dataTypes = property.getAsJsonObject().get("dataType").getAsJsonArray(); + if (dataTypes.size() == 1 && DataType.KNOWN_TYPES.contains(dataTypes.get(0).getAsString())) { + properties.add(property); + } else { + references.add(property); + } } } @@ -286,7 +289,7 @@ public CollectionConfig read(JsonReader in) throws IOException { // Separate modules into reranker- and generative- modules. var rerankerModules = new JsonArray(); - if (jsonObject.has("moduleConfig")) { + if (jsonObject.has("moduleConfig") && jsonObject.get("moduleConfig").isJsonObject()) { var moduleConfig = jsonObject.remove("moduleConfig").getAsJsonObject(); moduleConfig.entrySet().stream() diff --git a/src/test/java/io/weaviate/client6/v1/internal/json/JSONTest.java b/src/test/java/io/weaviate/client6/v1/internal/json/JSONTest.java index 82a205ae9..7763710a2 100644 --- a/src/test/java/io/weaviate/client6/v1/internal/json/JSONTest.java +++ b/src/test/java/io/weaviate/client6/v1/internal/json/JSONTest.java @@ -413,4 +413,14 @@ public void test_ReferenceAddManyResponse_CustomDeserializer() { .as("response contains 1 error") .hasSize(1); } + + @Test + public void test_CollectionConfig_read_empty() { + var json = """ + { "class": "BarebonesCollection" } + """; + Assertions.assertThatCode(() -> JSON.deserialize(json, CollectionConfig.class)) + .as("deserialize CollectionConfig with no properties") + .doesNotThrowAnyException(); + } }