Creating a webhook can result in host not found exceptions

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Low
    • None
    • Affects Version/s: 7.6.0
    • Component/s: Webhooks
    • 2
    • Severity 3 - Minor
    • 2

      Issue Summary

      This is reproducible on Data Center: yes

      Steps to Reproduce

      1. Launch Bitbucket instance with at least one project and repo
      2. Open the project settings page
      3. Open the webhooks settings page
      4. Add a new webhook (name: mydemo1, secret:123, url:http://test_template)
      5. Save the webhook
      6. Make a push to the repo
      7. Wait a minute or two
      8. In the logs you should see the below errors where url is null

       

      Expected Results

      Webhook has correct url set

      Actual Results

      The below exception is thrown in the xxxxxxx.log file:

      This will be thrown when the webhook is saved

      2022-02-01 05:15:42,851 WARN  [ForkJoinPool.commonPool-worker-54]  c.a.w.i.h.DefaultInvocationHistoryService Request to  resulted in an error: Host name may not be null 
      
      
      And this will be thrown every 30 seconds:
      2022-02-01 05:15:43,764 WARN  [atlassian-webhooks-scheduler:thread-1]  c.a.w.i.d.AsyncInvocationHistoryDao Failed to write webhook invocation data for 501:repo:refs_changed to the database java.lang.IllegalArgumentException: Cannot set non-null String field REQUEST_URL to ''         at org.apache.commons.lang3.Validate.isTrue(Validate.java:158)         at net.java.ao.EntityManager.create(EntityManager.java:350)         at net.java.ao.EntityManager.create(EntityManager.java:402)         at com.atlassian.activeobjects.internal.EntityManagedActiveObjects.create(EntityManagedActiveObjects.java:101)         at com.atlassian.activeobjects.osgi.TenantAwareActiveObjects.create(TenantAwareActiveObjects.java:272)         at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56)         at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60)         at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70)         at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53)         at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57)         at com.atlassian.webhooks.internal.dao.AoInvocationHistoryDao.saveInvocation(AoInvocationHistoryDao.java:301)         at com.atlassian.webhooks.internal.dao.AsyncInvocationHistoryDao.maybeFlush(AsyncInvocationHistoryDao.java:271)         at com.atlassian.webhooks.internal.dao.AsyncInvocationHistoryDao.lambda$flushPending$5(AsyncInvocationHistoryDao.java:240)         at com.atlassian.sal.core.transaction.HostContextTransactionTemplate$1.doInTransaction(HostContextTransactionTemplate.java:21)         at com.atlassian.stash.internal.sal.spi.HostContextAccessorImpl.doInTransaction(HostContextAccessorImpl.java:54)         at com.atlassian.sal.core.transaction.HostContextTransactionTemplate.execute(HostContextTransactionTemplate.java:18)         at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)         at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56)         at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60)         at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70)         at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53)         at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57)         at com.atlassian.webhooks.internal.dao.AsyncInvocationHistoryDao.flushPending(AsyncInvocationHistoryDao.java:239)         at com.atlassian.webhooks.internal.dao.AsyncInvocationHistoryDao.flush(AsyncInvocationHistoryDao.java:200)         at com.atlassian.webhooks.internal.dao.AsyncInvocationHistoryDao.flushAndReschedule(AsyncInvocationHistoryDao.java:229)         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)         at java.util.concurrent.FutureTask.run(FutureTask.java:266)         at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)         at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)         at java.lang.Thread.run(Thread.java:748)         ... 46 frames trimmed 

       

       

      Workaround

      Currently there is no known workaround for this behavior. A workaround will be added here when available

       

      Cause:

      atlassian-webhooks-plugin/plugin/src/main/java/com/atlassian/webhooks/internal/client/request/RawRequest.java uses `URI.create(url)` in `getUrl()` which returns null for `URI.getHost()` because the URL contains an underscore in the base url causing this issue. 

            Assignee:
            Unassigned
            Reporter:
            James Adams
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: