it-at-m / digiwf-core

central workflow automation and integration platform based on the free process framework Camunda.
MIT License
19 stars 7 forks source link

PresignedUrls can't be created for files with umlauts #1114

Closed simonhir closed 10 months ago

simonhir commented 10 months ago

The user wants to upload files which contains umlauts and these then can be used inside the process. When creating presigned Urls in a process for paths containing umlauts a exception in the camunda connector is thrown when trying to correlate them back to the process.

The problem seems to occur only for the new release.

Log ``` Message could not be sent. org.camunda.community.rest.client.invoker.ApiException: Invalid UTF-8 middle byte 0x74 at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 261] (through reference chain: org.camunda.bpm.engine.rest.dto.message.CorrelationMessageDto["processVariables"]->java.util.LinkedHashMap["presignedUrls"]->org.camunda.bpm.engine.rest.dto.VariableValueDto["value"]) at org.camunda.community.rest.client.invoker.ApiClient.processResponse(ApiClient.java:960) at org.camunda.community.rest.client.invoker.ApiClient.invokeAPI(ApiClient.java:1047) at org.camunda.community.rest.client.api.MessageApi.deliverMessage(MessageApi.java:108) at org.camunda.community.rest.client.api.MessageApi.deliverMessage(MessageApi.java:64) at de.muenchen.oss.digiwf.camunda.connector.message.MessageServiceImpl.correlateMessage(MessageServiceImpl.java:52) at de.muenchen.oss.digiwf.connector.message.internal.streaming.MessageEventConsumer.lambda$correlateMessage$0(MessageEventConsumer.java:29) at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.invokeConsumer(SimpleFunctionRegistry.java:1029) at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.doApply(SimpleFunctionRegistry.java:731) at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.apply(SimpleFunctionRegistry.java:577) at org.springframework.cloud.stream.function.PartitionAwareFunctionWrapper.apply(PartitionAwareFunctionWrapper.java:92) at org.springframework.cloud.stream.function.FunctionConfiguration$FunctionWrapper.apply(FunctionConfiguration.java:832) at org.springframework.cloud.stream.function.FunctionConfiguration$FunctionToDestinationBinder$1.handleMessageInternal(FunctionConfiguration.java:661) at org.springframework.integration.handler.AbstractMessageHandler.doHandleMessage(AbstractMessageHandler.java:105) at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73) at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:115) at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:133) at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:106) at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:72) at org.springframework.integration.channel.AbstractMessageChannel.sendInternal(AbstractMessageChannel.java:375) at org.springframework.integration.channel.AbstractMessageChannel.sendWithMetrics(AbstractMessageChannel.java:346) at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:326) at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:299) at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:187) at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:166) at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:47) at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:109) at org.springframework.integration.endpoint.MessageProducerSupport.lambda$sendMessage$1(MessageProducerSupport.java:262) at io.micrometer.observation.Observation.lambda$observe$0(Observation.java:493) at io.micrometer.observation.Observation.observeWithContext(Observation.java:603) at io.micrometer.observation.Observation.observe(Observation.java:492) at org.springframework.integration.endpoint.MessageProducerSupport.sendMessage(MessageProducerSupport.java:262) at org.springframework.integration.kafka.inbound.KafkaMessageDrivenChannelAdapter.sendMessageIfAny(KafkaMessageDrivenChannelAdapter.java:394) at org.springframework.integration.kafka.inbound.KafkaMessageDrivenChannelAdapter$IntegrationRecordMessageListener.onMessage(KafkaMessageDrivenChannelAdapter.java:469) at org.springframework.integration.kafka.inbound.KafkaMessageDrivenChannelAdapter$IntegrationRecordMessageListener.onMessage(KafkaMessageDrivenChannelAdapter.java:425) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeOnMessage(KafkaMessageListenerContainer.java:2873) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeOnMessage(KafkaMessageListenerContainer.java:2854) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.lambda$doInvokeRecordListener$57(KafkaMessageListenerContainer.java:2772) at io.micrometer.observation.Observation.lambda$observe$4(Observation.java:544) at io.micrometer.observation.Observation.observeWithContext(Observation.java:603) at io.micrometer.observation.Observation.observe(Observation.java:544) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeRecordListener(KafkaMessageListenerContainer.java:2770) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeWithRecords(KafkaMessageListenerContainer.java:2622) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeRecordListener(KafkaMessageListenerContainer.java:2508) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeListener(KafkaMessageListenerContainer.java:2150) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeIfHaveRecords(KafkaMessageListenerContainer.java:1505) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.pollAndInvoke(KafkaMessageListenerContainer.java:1469) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.run(KafkaMessageListenerContainer.java:1344) at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) at java.base/java.lang.Thread.run(Thread.java:840) ``` ``` org.springframework.messaging.MessageHandlingException: error occurred in message handler [org.springframework.cloud.stream.function.FunctionConfiguration$FunctionToDestinationBinder$1@bea5831], failedMessage=GenericMessage [payload=byte[722], headers={kafka_timestampType=CREATE_TIME, digiwf.messagename=createPresignedUrl, type=correlatemessagev01, kafka_receivedTopic=dwf-connector-processestest, kafka_offset=238, spring.cloud.stream.sendto.destination=dwf-connector-processestest, scst_nativeHeadersPresent=true, kafka_consumer=org.apache.kafka.clients.consumer.KafkaConsumer@48634396, digiwf.processinstanceid=553fc80b-9846-11ee-8510-0a580a8a4f75, kafka_receivedPartitionId=4, contentType=application/json, kafka_receivedTimestamp=1702313858422, kafka_groupId=dwf-digiwf-connector-processestest}] at org.springframework.integration.support.utils.IntegrationUtils.wrapInHandlingExceptionIfNecessary(IntegrationUtils.java:191) at org.springframework.integration.handler.AbstractMessageHandler.doHandleMessage(AbstractMessageHandler.java:108) at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73) at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:115) at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:133) at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:106) at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:72) at org.springframework.integration.channel.AbstractMessageChannel.sendInternal(AbstractMessageChannel.java:375) at org.springframework.integration.channel.AbstractMessageChannel.sendWithMetrics(AbstractMessageChannel.java:346) at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:326) at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:299) at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:187) at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:166) at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:47) at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:109) at org.springframework.integration.endpoint.MessageProducerSupport.lambda$sendMessage$1(MessageProducerSupport.java:262) at io.micrometer.observation.Observation.lambda$observe$0(Observation.java:493) at io.micrometer.observation.Observation.observeWithContext(Observation.java:603) at io.micrometer.observation.Observation.observe(Observation.java:492) at org.springframework.integration.endpoint.MessageProducerSupport.sendMessage(MessageProducerSupport.java:262) at org.springframework.integration.kafka.inbound.KafkaMessageDrivenChannelAdapter.sendMessageIfAny(KafkaMessageDrivenChannelAdapter.java:394) at org.springframework.integration.kafka.inbound.KafkaMessageDrivenChannelAdapter$IntegrationRecordMessageListener.onMessage(KafkaMessageDrivenChannelAdapter.java:469) at org.springframework.integration.kafka.inbound.KafkaMessageDrivenChannelAdapter$IntegrationRecordMessageListener.onMessage(KafkaMessageDrivenChannelAdapter.java:425) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeOnMessage(KafkaMessageListenerContainer.java:2873) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeOnMessage(KafkaMessageListenerContainer.java:2854) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.lambda$doInvokeRecordListener$57(KafkaMessageListenerContainer.java:2772) at io.micrometer.observation.Observation.lambda$observe$4(Observation.java:544) at io.micrometer.observation.Observation.observeWithContext(Observation.java:603) at io.micrometer.observation.Observation.observe(Observation.java:544) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeRecordListener(KafkaMessageListenerContainer.java:2770) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeWithRecords(KafkaMessageListenerContainer.java:2622) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeRecordListener(KafkaMessageListenerContainer.java:2508) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeListener(KafkaMessageListenerContainer.java:2150) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeIfHaveRecords(KafkaMessageListenerContainer.java:1505) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.pollAndInvoke(KafkaMessageListenerContainer.java:1469) at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.run(KafkaMessageListenerContainer.java:1344) at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) at java.base/java.lang.Thread.run(Thread.java:840) Caused by: java.lang.RuntimeException: ApiException{code=400, responseHeaders={X-Frame-Options=[DENY], Cache-Control=[no-cache, no-store, must-revalidate], X-Content-Type-Options=[nosniff], Connection=[close], X-XSS-Protection=[0], Content-Length=[365], Date=[Mon, 11 Dec 2023 16:57:38 GMT], Content-Type=[text/plain]}, responseBody='Invalid UTF-8 middle byte 0x74 at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 261] (through reference chain: org.camunda.bpm.engine.rest.dto.message.CorrelationMessageDto["processVariables"]->java.util.LinkedHashMap["presignedUrls"]->org.camunda.bpm.engine.rest.dto.VariableValueDto["value"])'} at de.muenchen.oss.digiwf.camunda.connector.message.MessageServiceImpl.correlateMessage(MessageServiceImpl.java:55) at de.muenchen.oss.digiwf.connector.message.internal.streaming.MessageEventConsumer.lambda$correlateMessage$0(MessageEventConsumer.java:29) at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.invokeConsumer(SimpleFunctionRegistry.java:1029) at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.doApply(SimpleFunctionRegistry.java:731) at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.apply(SimpleFunctionRegistry.java:577) at org.springframework.cloud.stream.function.PartitionAwareFunctionWrapper.apply(PartitionAwareFunctionWrapper.java:92) at org.springframework.cloud.stream.function.FunctionConfiguration$FunctionWrapper.apply(FunctionConfiguration.java:832) at org.springframework.cloud.stream.function.FunctionConfiguration$FunctionToDestinationBinder$1.handleMessageInternal(FunctionConfiguration.java:661) at org.springframework.integration.handler.AbstractMessageHandler.doHandleMessage(AbstractMessageHandler.java:105) ... 36 more Caused by: ApiException{code=400, responseHeaders={X-Frame-Options=[DENY], Cache-Control=[no-cache, no-store, must-revalidate], X-Content-Type-Options=[nosniff], Connection=[close], X-XSS-Protection=[0], Content-Length=[365], Date=[Mon, 11 Dec 2023 16:57:38 GMT], Content-Type=[text/plain]}, responseBody='Invalid UTF-8 middle byte 0x74 at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 261] (through reference chain: org.camunda.bpm.engine.rest.dto.message.CorrelationMessageDto["processVariables"]->java.util.LinkedHashMap["presignedUrls"]->org.camunda.bpm.engine.rest.dto.VariableValueDto["value"])'} at org.camunda.community.rest.client.invoker.ApiClient.processResponse(ApiClient.java:960) at org.camunda.community.rest.client.invoker.ApiClient.invokeAPI(ApiClient.java:1047) at org.camunda.community.rest.client.api.MessageApi.deliverMessage(MessageApi.java:108) at org.camunda.community.rest.client.api.MessageApi.deliverMessage(MessageApi.java:64) at de.muenchen.oss.digiwf.camunda.connector.message.MessageServiceImpl.correlateMessage(MessageServiceImpl.java:52) ... 44 more ```

Reference

https://git.muenchen.de/digitalisierung/digiwf-support/-/issues/416

Acceptance criteria

simonhir commented 10 months ago

@lmoesle @zambrovski wäre super wenn ihr euch das morgen anschauen könntet.

// call stack
de/muenchen/oss/digiwf/camunda/connector/message/MessageServiceImpl.java:52
org/camunda/community/camunda-engine-rest-client-openapi-java/7.20.2/camunda-engine-rest-client-openapi-java-7.20.2-sources.jar!/org/camunda/community/rest/client/api/MessageApi.java:76
org/camunda/community/camunda-engine-rest-client-openapi-java/7.20.2/camunda-engine-rest-client-openapi-java-7.20.2-sources.jar!/org/camunda/community/rest/client/invoker/ApiClient.java:1033
// "wrong" content type is loaded
org/camunda/community/camunda-engine-rest-client-openapi-java/7.20.2/camunda-engine-rest-client-openapi-java-7.20.2-sources.jar!/org/camunda/community/rest/client/invoker/ApiClient.java:703->getContentType

getContetntType liefert einen ContentType mit charset null was dazu führt, dass das default Charset beim serializen auf ISO_8859_1 gesetzt wird.

// call serialization
org/camunda/community/camunda-engine-rest-client-openapi-java/7.20.2/camunda-engine-rest-client-openapi-java-7.20.2-sources.jar!/org/camunda/community/rest/client/invoker/ApiClient.java:1037
// create StringEntity
org/camunda/community/camunda-engine-rest-client-openapi-java/7.20.2/camunda-engine-rest-client-openapi-java-7.20.2-sources.jar!/org/camunda/community/rest/client/invoker/ApiClient.java:735
// default charset is loaded
org/apache/httpcomponents/core5/httpcore5/5.2.3/httpcore5-5.2.3-sources.jar!/org/apache/hc/core5/http/io/entity/StringEntity.java:65

Insgesamt scheint das Verhalten durch das Paket org.apache.hc.core5.http zu kommen, welches von dem camunda-rest-client angezogen wird.

zambrovski commented 10 months ago

Wir können auch einen anderen Client verwenden...

lmoesle commented 10 months ago

@zambrovski Gibt's einen Client, den du empfehlen kannst?

Ich versuche gerade https://github.com/camunda-community-hub/camunda-platform-7-rest-client-spring-boot im Connector einzubauen. Ich habe aber aktuell noch BeanInstanciationErrors, die ich aktuell versuche zu fixen

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.camunda.community.rest.client.api.AuthorizationApi]: Factory method 'authorizationApi' threw exception with message: org.camunda.community.rest.client.api.AuthorizationApi
lmoesle commented 10 months ago

Mit dem https://github.com/camunda-community-hub/camunda-platform-7-rest-client-spring-boot tritt der Fehler nicht auf. Ich stelle jetzt auch noch die anderen REST Api Calls auf die Bibliothek um und mache dann einen PR auf.

zambrovski commented 10 months ago

Den meinte ich auch...