From e3094f8a32aa5ef8be8a816ef6fe42bc5ea8513c Mon Sep 17 00:00:00 2001 From: Andrew Byrd Date: Wed, 2 Oct 2024 12:17:21 -0400 Subject: [PATCH] strict objectmapper to detect misspelled fields --- .../com/conveyal/analysis/controllers/BundleController.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/conveyal/analysis/controllers/BundleController.java b/src/main/java/com/conveyal/analysis/controllers/BundleController.java index dc3034583..4f26d0aed 100644 --- a/src/main/java/com/conveyal/analysis/controllers/BundleController.java +++ b/src/main/java/com/conveyal/analysis/controllers/BundleController.java @@ -21,6 +21,7 @@ import com.conveyal.r5.analyst.progress.ProgressInputStream; import com.conveyal.r5.analyst.cluster.TransportNetworkConfig; import com.conveyal.r5.analyst.progress.Task; +import com.conveyal.r5.common.JsonUtilities; import com.conveyal.r5.streets.OSMCache; import com.conveyal.r5.util.ExceptionUtils; import com.mongodb.QueryBuilder; @@ -136,8 +137,9 @@ private Bundle create (Request req, Response res) { if (files.get("config") != null) { // For validation, rather than reading as freeform JSON, deserialize into a model class instance. // However, only the instance fields specifying things other than OSM and GTFS IDs will be retained. + // Use strict object mapper (from the strict/lenient pair) to fail on misspelled field names. String configString = files.get("config").get(0).getString(); - bundle.config = JsonUtil.objectMapper.readValue(configString, TransportNetworkConfig.class); + bundle.config = JsonUtilities.objectMapper.readValue(configString, TransportNetworkConfig.class); } UserPermissions userPermissions = UserPermissions.from(req); bundle.accessGroup = userPermissions.accessGroup;