java.lang.IllegalArgumentException if webhook URL contains variables not relevant to the event

XMLWordPrintable

    • 10.01
    • 6
    • Severity 3 - Minor
    • 0

      Issue Summary

      This is reproducible on Data Center: (yes)

      adding version.id context parameter in a webhook can cause java.lang.IllegalArgumentException if the webhook is trigger with non-version event.

      Steps to Reproduce

      1. Create a webhook with context parameter like https://example.com/webhook?version=\{version.id}&issue={issue.id}
      2. Add issue events and version events (issue created, updated, version created, updated)
      3. update or create an issue in Jira which should trigger the webhook

      Expected Results

      The webhook should fire successfully, since the trigger wasn't version related, version.id should be empty and we should receive a webhook like this.

      https://example.com/webhook?version=&issue=<ISSUE_ID>
      

      Actual Results

      The webhook isn't sent. And, in atlassian-jira.log we see the below exception:

      2025-02-07 01:58:19,774+0000 ForkJoinPool.commonPool-worker-5 WARN      [c.a.w.internal.publish.DefaultWebhookDispatcher] Webhook invocation [10ad514a-0837-474d-882d-f979d1a5ce9a] to [https://webhook-tester.dev.services.atlassian.com/nfarhad?version={version.id}&issue={issue.key}] failed with an error
      java.lang.IllegalArgumentException: Illegal character in query at index 66: https://webhook-tester.dev.services.atlassian.com/nfarhad?version={version.id}&issue=FSP-2
          at java.base/java.net.URI.create(URI.java:906)
          at com.atlassian.webhooks.internal.client.request.RawRequest.getUrl(RawRequest.java:95)
          at com.atlassian.webhooks.internal.client.request.DefaultRequestExecutor.execute(DefaultRequestExecutor.java:57)
          at com.atlassian.webhooks.internal.publish.DefaultWebhookDispatcher.dispatch(DefaultWebhookDispatcher.java:84)
          at com.atlassian.webhooks.internal.DefaultWebhookService.lambda$publish$9(DefaultWebhookService.java:288)
          at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
          at com.atlassian.webhooks.internal.DefaultWebhookService.lambda$publish$10(DefaultWebhookService.java:285)
          at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
          at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
          at java.base/java.lang.Thread.run(Thread.java:840)
      Caused by: java.net.URISyntaxException: Illegal character in query at index 66: https://webhook-tester.dev.services.atlassian.com/nfarhad?version={version.id}&issue=FSP-2
          at java.base/java.net.URI$Parser.fail(URI.java:2976)
          at java.base/java.net.URI$Parser.checkChars(URI.java:3147)
          at java.base/java.net.URI$Parser.parseHierarchical(URI.java:3235)
          at java.base/java.net.URI$Parser.parse(URI.java:3177)
          at java.base/java.net.URI.<init>(URI.java:623)
          at java.base/java.net.URI.create(URI.java:904)
          ... 9 more

      Instead of expanding version.id to an empty value, the webhook tries to send *

      {version.id}
      • as the value. And, the curly braces cause java.lang.IllegalArgumentException

        Workaround

      This affects Jira version 10. Versions <10 aren't affected. As a workaround, we can create separate webhooks and only have version events as triggers when using version.id context parameter.

              Assignee:
              Unassigned
              Reporter:
              Nashid Farhad
              Votes:
              4 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated: