Insight Automation fails to handle Azure webhook URL due to incorrect encoding

XMLWordPrintable

    • 1
    • Severity 2 - Major
    • 1

      Issue Summary

      Insight Automation to send POST payload to Azure webhook doesn't work

      Steps to Reproduce

      On Azure Side:

      On Insight side:

      • Create a sample Automation rule like this:
      • Trigger the automation by updating the selected object type

      Expected Results

      • the triggered automation does send the payload to the Azure webhook endpoint

      Actual Results

      • We see the insight_automation.log does show a successful HTTP request sent:
        2021-10-08 12:25:17,445 [insight-event-0] | Got rule and event for insightObjectAsyncEvent: null, id: 1 - InsightObjectEvent eventType: OBJECT_UPDATED, rule id: 1, name: Testing Azure Webhook, isActive true, objectRuleEvent id: 1 and object: Dell PowerEdge VRTX (MOS-17)
        2021-10-08 12:25:17,448 [insight-event-0] | doAction(), called for event class: InsightObjectUpdatedEvent
        2021-10-08 12:25:17,448 [insight-event-0] | Object name: Dell PowerEdge VRTX, id: 17
        2021-10-08 12:25:17,448 [insight-event-0] | Execute Rule action (AutomationRuleHttpRequestAction): Start, id: 1, event [id: 1, iql: No iql], condition: objectType = Server
        2021-10-08 12:25:17,924 [insight-event-0] | Execute Rule action (AutomationRuleHttpRequestAction), Result: POST executed. Url: https://dc14d534-86de-4a0b-852a-471ff06c9ed2.webhook.dewc.azure-automation.net/webhooks?token=vjzcXzm2d5hXCJn2cUlmbRv7t8A81eiQRDxEn3Iv7gg%3d data: {
            "Key": MOS-17
        }
        2021-10-08 12:25:17,924 [insight-event-0] | Execute Rule action (AutomationRuleHttpRequestAction): Done, id:1, event [id: 1, iql: No iql, condition: objectType = Server
        
      • However, Azure doesn't receive this payload and in the atlassian-jira.log the below FileNotFoundException exception is thrown:
        2021-10-08 12:25:17,921+0000 insight-event-0 ERROR admin     [c.r.j.p.i.services.util.InsightHttpRequester] InsightHttpRequester.doRequest() Failed to send Http request for data: {"url":"https://dc14d534-86de-4a0b-852a-471ff06c9ed2.webhook.dewc.azure-automation.net/webhooks?token=vjzcXzm2d5hXCJn2cUlmbRv7t8A81eiQRDxEn3Iv7gg%3d","method":"POST","postData":"{\n    \"Key\": MOS-17\n}","username":null,"password":"********"}
        java.io.FileNotFoundException: https://dc14d534-86de-4a0b-852a-471ff06c9ed2.webhook.dewc.azure-automation.net/webhooks?token=vjzcXzm2d5hXCJn2cUlmbRv7t8A81eiQRDxEn3Iv7gg%253d
        	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1920)
        	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520)
        	at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:250)
        	at com.riadalabs.jira.plugins.insight.services.util.InsightHttpRequester.doRequest(InsightHttpRequester.java:82)
        	at com.riadalabs.jira.plugins.insight.services.automation.action.AutomationRuleHttpRequestAction.doActionSafe(AutomationRuleHttpRequestAction.java:56)
        	at com.riadalabs.jira.plugins.insight.services.automation.action.AbstractInsightAutomationAction.doAction(AbstractInsightAutomationAction.java:107)
        	at com.riadalabs.jira.plugins.insight.services.automation.rule.impl.AutomationRuleEngineImpl.executeAction(AutomationRuleEngineImpl.java:675)
        	at com.riadalabs.jira.plugins.insight.services.automation.rule.impl.AutomationRuleEngineImpl.executeActions(AutomationRuleEngineImpl.java:660)
        	at com.riadalabs.jira.plugins.insight.services.automation.rule.impl.AutomationRuleEngineImpl.matchConditionAndExecuteActions(AutomationRuleEngineImpl.java:453)
        	at com.riadalabs.jira.plugins.insight.services.automation.rule.impl.AutomationRuleEngineImpl.executeAsConfiguredUser(AutomationRuleEngineImpl.java:261)
        	at com.riadalabs.jira.plugins.insight.services.automation.rule.impl.AutomationRuleEngineImpl.handleAsyncEvent(AutomationRuleEngineImpl.java:214)
        	at com.riadalabs.jira.plugins.insight.services.automation.event.AutomationRuleEventListener.onAsyncEvent(AutomationRuleEventListener.java:94)
        	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:87)
        	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:144)
        	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:72)
        	at com.atlassian.sal.core.executor.ThreadLocalDelegateRunnable.run(ThreadLocalDelegateRunnable.java:34)
        	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        	at java.base/java.lang.Thread.run(Thread.java:829)
        
      • Notice how the URL gets further encoded by Jira:
      Actual URL Jira Encoded URL
      https://dc14d534-86de-4a0b-852a-471ff06c9ed2.webhook.dewc.azure-automation.net/webhooks?token=vjzcXzm2d5hXCJn2cUlmbRv7t8A81eiQRDxEn3Iv7gg%3d
      https://dc14d534-86de-4a0b-852a-471ff06c9ed2.webhook.dewc.azure-automation.net/webhooks?token=vjzcXzm2d5hXCJn2cUlmbRv7t8A81eiQRDxEn3Iv7gg%253d
      Azure Token '%3d' Gets encoded as '%253d'

      Workaround

      • Replace the %3d at the end of the token with = in the URL so that when it tries to encode again it coverts it to %3d in the token

            Assignee:
            François Dénommée (Inactive)
            Reporter:
            Suddha
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: