@@ -216,7 +216,10 @@ public class SetAction implements SettingsWsAction { | |||
.map(oneFieldValues -> readOneFieldValues(oneFieldValues, request.getKey())) | |||
.flatMap(map -> map.entrySet().stream()) | |||
.peek(entry -> valuesByFieldKeys.put(entry.getKey(), entry.getValue())) | |||
.forEach(entry -> checkRequest(fieldKeys.contains(entry.getKey()), "Unknown field key '%s' for setting '%s'", entry.getKey(), request.getKey())); | |||
.forEach(entry -> { | |||
checkRequest(fieldKeys.contains(entry.getKey()), "Unknown field key '%s' for setting '%s'", entry.getKey(), request.getKey()); | |||
checkRequest(entry.getValue() != null, "Parameter field '%s' must not be null", entry.getKey()); | |||
}); | |||
checkFieldType(request, definition, valuesByFieldKeys); | |||
} |
@@ -544,6 +544,29 @@ public class SetActionTest { | |||
callForGlobalPropertySet("my.key", newArrayList(GSON.toJson(ImmutableMap.of("field", "notAnInt")))); | |||
} | |||
@Test | |||
public void fail_when_property_set_has_a_null_field_value() { | |||
propertyDefinitions.addComponent(PropertyDefinition | |||
.builder("my.key") | |||
.name("foo") | |||
.description("desc") | |||
.category("cat") | |||
.subCategory("subCat") | |||
.type(PropertyType.PROPERTY_SET) | |||
.defaultValue("default") | |||
.fields(newArrayList( | |||
PropertyFieldDefinition.build("field") | |||
.name("Field") | |||
.type(PropertyType.STRING) | |||
.build())) | |||
.build()); | |||
expectedException.expect(BadRequestException.class); | |||
expectedException.expectMessage("Parameter field 'field' must not be null"); | |||
callForGlobalPropertySet("my.key", newArrayList("{\"field\": null}")); | |||
} | |||
@Test | |||
public void fail_when_property_set_with_invalid_json() { | |||
propertyDefinitions.addComponent(PropertyDefinition |