Repository: gisaia/ARLAS-server (language: python)

Issue:
Creation of a collection with typo in geometry_path properties key does not raise errors
As an ARLAS-Server user.
I create a collection with the wrong body :
{
    "index_name": "occitanie_data_pop",
    "id_path": "idINSPIRE",
    "timestamp_path": "@timestamp",
    "centroid_path": "centroid",
    "geom**a**try_path": "geom"
}

The collection is created normally but the _search and _geosearch endpoint does not work.

-Why the geometry_path is not required to create a collection ?



Discussion / hints:

Fix patch:
diff --git a/arlas-core/src/main/java/io/arlas/server/core/exceptions/ConstraintViolationExceptionMapper.java b/arlas-core/src/main/java/io/arlas/server/core/exceptions/ConstraintViolationExceptionMapper.java
index 0096ab86d..ab9757165 100644
--- a/arlas-core/src/main/java/io/arlas/server/core/exceptions/ConstraintViolationExceptionMapper.java
+++ b/arlas-core/src/main/java/io/arlas/server/core/exceptions/ConstraintViolationExceptionMapper.java
@@ -37,6 +37,6 @@ public Response toResponse(ConstraintViolationException e) {
             logger.error("! " + s.toString());
         }
         return ArlasException.getResponse(e, Response.Status.BAD_REQUEST,
-                "Invalid JSON parameter. Field `indexName` is mandatory.");
+                "Invalid JSON parameter. One required field is missing, either: `index_name`, `id_path`, `geometry_path`, `centroid_path` or `timestamp_path`.");
     }
 }
diff --git a/arlas-core/src/main/java/io/arlas/server/core/model/CollectionReferenceParameters.java b/arlas-core/src/main/java/io/arlas/server/core/model/CollectionReferenceParameters.java
index 433564baf..4e3f249d2 100644
--- a/arlas-core/src/main/java/io/arlas/server/core/model/CollectionReferenceParameters.java
+++ b/arlas-core/src/main/java/io/arlas/server/core/model/CollectionReferenceParameters.java
@@ -38,18 +38,22 @@ public class CollectionReferenceParameters implements Serializable {
     @JsonProperty(value = "index_name", required = true)
     public String indexName;
 
+    @NotEmpty
     @JsonProperty(value = "id_path", required = true)
     public String idPath;
 
+    @NotEmpty
     @JsonProperty(value = "geometry_path", required = true)
     public String geometryPath;
 
+    @NotEmpty
     @JsonProperty(value = "centroid_path", required = true)
     public String centroidPath;
 
     @JsonProperty(value = "h3_path", required = false)
     public String h3Path;
 
+    @NotEmpty
     @JsonProperty(value = "timestamp_path", required = true)
     public String timestampPath;
 


Test patch:
diff --git a/arlas-tests/src/test/java/io/arlas/server/tests/rest/collections/CollectionServiceIT.java b/arlas-tests/src/test/java/io/arlas/server/tests/rest/collections/CollectionServiceIT.java
index be308e0da..997a2e3b3 100644
--- a/arlas-tests/src/test/java/io/arlas/server/tests/rest/collections/CollectionServiceIT.java
+++ b/arlas-tests/src/test/java/io/arlas/server/tests/rest/collections/CollectionServiceIT.java
@@ -40,7 +40,7 @@ public class CollectionServiceIT extends AbstractTestWithCollection {
 
     @Test
     public void test00NotFoundCollectionParameters() throws Exception {
-        Map<String, Object> jsonAsMap = new HashMap<>();
+        Map<String, Object> jsonAsMap = getJsonAsMap();
         jsonAsMap.put(CollectionReference.INDEX_NAME, DataSetTool.DATASET_INDEX_NAME);
         jsonAsMap.put(CollectionReference.INSPIRE_PATH, getInspireJsonAsMap());
         jsonAsMap.put(CollectionReference.DUBLIN_CORE_PATH, getDublinJsonAsMap());