Skip to content

Commit a725009

Browse files
authoredFeb 11, 2025
Merge pull request #2118 from beyonnex-io/bugfix/wot-response-message-validation-regression
fixed regression in message response WoT validation done at wrong place
2 parents 1302aaa + b2b306b commit a725009

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed
 

‎things/service/src/main/java/org/eclipse/ditto/things/service/enforcement/ThingEnforcerActor.java

+2-17
Original file line numberDiff line numberDiff line change
@@ -715,18 +715,6 @@ private CompletionStage<Void> performWotBasedFeatureMessageValidation(final Mess
715715
((MessageCommandResponse<JsonValue, ?>) messageCommandResponse)
716716
.getMessage();
717717

718-
if (message.getPayload().isPresent() && !isJsonMessageContent(message)) {
719-
return CompletableFuture.failedFuture(
720-
WotThingModelPayloadValidationException
721-
.newBuilder("Could not validate non-JSON message content type <" +
722-
message.getContentType().orElse("?") + "> for message response subject " +
723-
"<" + message.getSubject() + ">"
724-
)
725-
.dittoHeaders(messageCommandResponse.getDittoHeaders())
726-
.build()
727-
);
728-
}
729-
730718
// lazily only supply JsonValue if validation is enabled for the message:
731719
final Supplier<JsonValue> messageCommandPayloadSupplier = () -> {
732720
if (message.getPayload().isPresent() && !isJsonMessageContent(message)) {
@@ -742,9 +730,7 @@ private CompletionStage<Void> performWotBasedFeatureMessageValidation(final Mess
742730
return message.getPayload().orElse(null);
743731
};
744732

745-
final MessageDirection messageDirection = message.getDirection();
746-
if (messageDirection == MessageDirection.TO &&
747-
messageCommandResponse instanceof SendThingMessageResponse<?> sendThingMessageResponse) {
733+
if (messageCommandResponse instanceof SendThingMessageResponse<?> sendThingMessageResponse) {
748734
return resolveThingDefinition()
749735
.thenCompose(optThingDefinition -> thingModelValidator.validateThingActionOutput(
750736
optThingDefinition.orElse(null),
@@ -754,8 +740,7 @@ private CompletionStage<Void> performWotBasedFeatureMessageValidation(final Mess
754740
sendThingMessageResponse.getDittoHeaders()
755741
))
756742
.thenApply(aVoid -> messageCommandResponse);
757-
} else if (messageDirection == MessageDirection.TO &&
758-
messageCommandResponse instanceof SendFeatureMessageResponse<?> sendFeatureMessageResponse) {
743+
} else if (messageCommandResponse instanceof SendFeatureMessageResponse<?> sendFeatureMessageResponse) {
759744
final String featureId = sendFeatureMessageResponse.getFeatureId();
760745
return resolveThingAndFeatureDefinition(featureId)
761746
.thenCompose(optDefinitionPair -> thingModelValidator.validateFeatureActionOutput(

0 commit comments

Comments
 (0)
Please sign in to comment.