This is an automated email from the ASF dual-hosted git repository.
jsinovassinnaik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/master by this push:
new 64aa2a874 UNOMI-846: improve log for event validation (#687)
64aa2a874 is described below
commit 64aa2a87446694e497991a3b5cdcfebd3039a48e
Author: jsinovassin <[email protected]>
AuthorDate: Mon Oct 14 18:29:10 2024 +0100
UNOMI-846: improve log for event validation (#687)
---
.../org/apache/unomi/schema/impl/SchemaServiceImpl.java | 13 +++++++------
rest/src/main/java/org/apache/unomi/utils/HttpUtils.java | 2 --
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git
a/extensions/json-schema/services/src/main/java/org/apache/unomi/schema/impl/SchemaServiceImpl.java
b/extensions/json-schema/services/src/main/java/org/apache/unomi/schema/impl/SchemaServiceImpl.java
index 2bd481f20..da7efeac2 100644
---
a/extensions/json-schema/services/src/main/java/org/apache/unomi/schema/impl/SchemaServiceImpl.java
+++
b/extensions/json-schema/services/src/main/java/org/apache/unomi/schema/impl/SchemaServiceImpl.java
@@ -85,9 +85,9 @@ public class SchemaServiceImpl implements SchemaService {
try {
JsonNode jsonNode = parseData(data);
JsonSchema jsonSchema = getJsonSchema(schemaId);
- return validate(jsonNode, jsonSchema).size() == 0;
+ return validate(jsonNode, jsonSchema).isEmpty();
} catch (ValidationException e) {
- LOGGER.debug("{}", e.getMessage(), e);
+ LOGGER.warn("{}", e.getMessage(), e);
}
return false;
}
@@ -102,7 +102,7 @@ public class SchemaServiceImpl implements SchemaService {
try {
return validateEvent(event).isEmpty();
} catch (ValidationException e) {
- LOGGER.debug("{}", e.getMessage(), e);
+ LOGGER.warn("{}", e.getMessage(), e);
}
return false;
}
@@ -134,6 +134,7 @@ public class SchemaServiceImpl implements SchemaService {
}
}
} catch (ValidationException e) {
+ LOGGER.warn("An error occurred during the validation of your
event - switch to DEBUG log level for more information.");
LOGGER.debug("Validation error : {}", e.getMessage());
Set<ValidationError> errors =
buildCustomErrorMessage(e.getMessage());
String eventTypeOrErrorKey = eventType != null ? eventType :
GENERIC_ERROR_KEY;
@@ -225,10 +226,10 @@ public class SchemaServiceImpl implements SchemaService {
try {
Set<ValidationMessage> validationMessages =
jsonSchema.validate(jsonNode);
- if (LOGGER.isDebugEnabled() && !validationMessages.isEmpty()) {
- LOGGER.debug("Schema validation found {} errors while
validating against schema: {}", validationMessages.size(),
jsonSchema.getCurrentUri());
+ if (!validationMessages.isEmpty()) {
+ LOGGER.warn("Schema validation found {} errors while
validating against schema: {}", validationMessages.size(),
jsonSchema.getCurrentUri());
for (ValidationMessage validationMessage : validationMessages)
{
- LOGGER.debug("Validation error: {}", validationMessage);
+ LOGGER.warn("Validation error: {}", validationMessage);
}
}
diff --git a/rest/src/main/java/org/apache/unomi/utils/HttpUtils.java
b/rest/src/main/java/org/apache/unomi/utils/HttpUtils.java
index 99096ec56..2ed4b4027 100644
--- a/rest/src/main/java/org/apache/unomi/utils/HttpUtils.java
+++ b/rest/src/main/java/org/apache/unomi/utils/HttpUtils.java
@@ -123,8 +123,6 @@ public class HttpUtils {
for (JsonNode event : eventsNode) {
if (schemaService.isEventValid(event.toString())) {
filteredEvents.add(jsonParser.getCodec().treeToValue(event,
Event.class));
- } else {
- LOGGER.error("An event was rejected - switch to DEBUG log
level for more information OR test the payload of your event against the
\"validateEvent\" endpoint.");
}
}
return filteredEvents;