Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Slack intermediate catch event breaks on event subscription #1015

Closed
igpetrov opened this issue Aug 9, 2023 · 3 comments
Closed
Assignees

Comments

@igpetrov
Copy link
Contributor

igpetrov commented Aug 9, 2023

Describe the issue

Intermediate catch event fails on the first request (challenge echo) because the proposed Correlation key (payload) field, suggested by the doc as request.body.event.text is never present but looks like {"token":"XXX","challenge":"YYY","type":"url_verification"} thus failing with 500.

While this is expected behaviour, 500 is not an option an degrades overall user experience when building an element template with Slack intermediate connector.

As a workaround suggested: if request.body.event = null then "" else request.body.event.text instead of request.body.event.text at least until we find a better approach.

Steps to Reproduce

  1. Fill element template as per screenshot.
  2. Deploy and start
  3. Go to api.slack.com -> event subscriptions
  4. Set an endpoint for events the one you obtained from BPMN
  5. Get a lovely stack trace
io.camunda.connector.api.error.ConnectorInputException: io.camunda.connector.feel.FeelEngineWrapperException: Failed to evaluate expression '=request.body.event.text' in context 'WebhookTriggerResultContext[request=MappedHttpRequest[body={token=7w09PLZYUTFowXae6D63cCAz, challenge=hIIgdmJlDg8TNBjGJNgWD3hF7VF3zzyWeFJfAmaYEboTey1uHzjP, type=url_verification}, headers={host=localhost:8080, user-agent=curl/7.88.1, accept=*/*, content-type=application/json, x-slack-request-timestamp=1691588067, x-slack-signature=v0=5191aa1a466c86a1367a173c191873be19a442728047ea198c67dc97bd6ab84e, content-length=129}, params={}], connectorData={}]'. Reason: failed to evaluate expression 'request.body.event.text': context contains no entry with key 'event'
	at io.camunda.connector.runtime.core.inbound.correlation.InboundCorrelationHandler.extractCorrelationKey(InboundCorrelationHandler.java:161)
	at io.camunda.connector.runtime.core.inbound.correlation.InboundCorrelationHandler.triggerMessage(InboundCorrelationHandler.java:110)
	at io.camunda.connector.runtime.core.inbound.correlation.InboundCorrelationHandler.correlate(InboundCorrelationHandler.java:61)
	at io.camunda.connector.runtime.inbound.lifecycle.MeteredInboundCorrelationHandler.correlate(MeteredInboundCorrelationHandler.java:54)
	at io.camunda.connector.runtime.core.inbound.InboundConnectorContextImpl.correlate(InboundConnectorContextImpl.java:67)
	at io.camunda.connector.runtime.inbound.webhook.InboundWebhookRestController.processWebhook(InboundWebhookRestController.java:95)
	at io.camunda.connector.runtime.inbound.webhook.InboundWebhookRestController.lambda$inbound$0(InboundWebhookRestController.java:83)
	at java.base/java.util.Optional.map(Optional.java:260)
	at io.camunda.connector.runtime.inbound.webhook.InboundWebhookRestController.inbound(InboundWebhookRestController.java:78)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:884)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1081)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:974)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1011)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:914)
	at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:590)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885)
	at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
	at org.springframework.web.filter.ServerHttpObservationFilter.doFilterInternal(ServerHttpObservationFilter.java:109)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:166)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:894)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1740)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: io.camunda.connector.feel.FeelEngineWrapperException: Failed to evaluate expression '=request.body.event.text' in context 'WebhookTriggerResultContext[request=MappedHttpRequest[body={token=7w09PLZYUTFowXae6D63cCAz, challenge=hIIgdmJlDg8TNBjGJNgWD3hF7VF3zzyWeFJfAmaYEboTey1uHzjP, type=url_verification}, headers={host=localhost:8080, user-agent=curl/7.88.1, accept=*/*, content-type=application/json, x-slack-request-timestamp=1691588067, x-slack-signature=v0=5191aa1a466c86a1367a173c191873be19a442728047ea198c67dc97bd6ab84e, content-length=129}, params={}], connectorData={}]'. Reason: failed to evaluate expression 'request.body.event.text': context contains no entry with key 'event'
	at io.camunda.connector.feel.FeelEngineWrapper.evaluate(FeelEngineWrapper.java:115)
	at io.camunda.connector.feel.FeelEngineWrapper.evaluate(FeelEngineWrapper.java:120)
	at io.camunda.connector.runtime.core.inbound.correlation.InboundCorrelationHandler.extractCorrelationKey(InboundCorrelationHandler.java:159)
	... 62 common frames omitted
Caused by: java.lang.RuntimeException: failed to evaluate expression 'request.body.event.text': context contains no entry with key 'event'
	at io.camunda.connector.feel.FeelEngineWrapper.evaluateInternal(FeelEngineWrapper.java:154)
	at io.camunda.connector.feel.FeelEngineWrapper.evaluate(FeelEngineWrapper.java:113)
	... 64 common frames omitted
Screenshot 2023-08-09 at 17 05 06

Suggested fix

  • Perform implicit checks for authentication / challenge validation, or
  • Note this in docs, or
  • Prefill the Correlation key (payload) field with safe values, or
  • Combination of these.

Environment

  • All
@igpetrov igpetrov added the kind:bug Something isn't working label Aug 9, 2023
@igpetrov igpetrov self-assigned this Aug 9, 2023
@igpetrov igpetrov removed the kind:bug Something isn't working label Aug 11, 2023
@bastiankoerber
Copy link

need to be discussed in Architecture discussion. @igpetrov will share his thoughts in the architecture sync

@igpetrov
Copy link
Contributor Author

With the 8.3.0 release it is throwing a new error:

InboundConnectorDefinitionImpl{correlationPoint=MessageCorrelationPoint[messageName=7db62ede-e85c-48cf-ad58-493bdc1fb21b, correlationKeyExpression==if request.body.event = null then "" else request.body.event.text, messageIdExpression=null], bpmnProcessId='Process_1gcw0hi', version=9, processDefinitionKey=2251799813686572, elementId='Event_1numar1, tenantId='null'} failed with exception
io.camunda.connector.api.error.ConnectorException: java.lang.NullPointerException
	at io.camunda.connector.runtime.core.inbound.correlation.InboundCorrelationHandler.triggerMessage(InboundCorrelationHandler.java:232)
	at io.camunda.connector.runtime.core.inbound.correlation.InboundCorrelationHandler.correlate(InboundCorrelationHandler.java:68)
	at io.camunda.connector.runtime.core.inbound.correlation.InboundCorrelationHandler.correlate(InboundCorrelationHandler.java:56)
	at io.camunda.connector.runtime.inbound.lifecycle.MeteredInboundCorrelationHandler.correlate(MeteredInboundCorrelationHandler.java:54)
	at io.camunda.connector.runtime.core.inbound.InboundConnectorContextImpl.correlate(InboundConnectorContextImpl.java:66)
	at io.camunda.connector.runtime.inbound.webhook.InboundWebhookRestController.processWebhook(InboundWebhookRestController.java:95)
	at io.camunda.connector.runtime.inbound.webhook.InboundWebhookRestController.lambda$inbound$0(InboundWebhookRestController.java:83)
	at java.base/java.util.Optional.map(Unknown Source)
	at io.camunda.connector.runtime.inbound.webhook.InboundWebhookRestController.inbound(InboundWebhookRestController.java:78)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:884)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleIntern… [message truncated due to size] 

Investigating

@igpetrov
Copy link
Contributor Author

Fixed in 8.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants