Uploaded image for project: 'Elements Connect'
  1. Elements Connect
  2. CO-3613

Error when executing a request on an AppLink datasource if the query contains velocity on multiple lines

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 5.13.29, 6.0.7
    • Fix Version/s: 6.0.9
    • Labels:
      None
    • Functional components:
      Datasource - App link
      Runtime - Field Edition
      Velocity

      Description

      How to reproduce

      • Create an AppLink (OAuth with impersonation) between a Jira and a Confluence
      • Create a TEST space, opened to anyone
      • Create an Elements Connect field, plugged to the Confluence datasource
      • Paste this query:
        #if($userInput.length()>0)
        rest/api/content/search?cql=$util.encodeURIComponent('space=TEST and type = page and text ~ "')$userInput.urlEncode()$util.encodeURIComponent('*"')
        #else
        $query.abort()
        #end
        
      • Use this as root elements: $.results
      • And create two columns: $.id and $.title
      • "id" is the Key, and "title" the Template
      • Save the configuration
      • Add the field on an Edit screen
      • Edit the issue, and try to select a value ("home" should return the home page of the TEST space)

      Current

      • The field doesn't work and returns briefly an error message:
      • In the logs:
        2019-08-16 10:01:56,294 http-nio-8080-exec-5 WARN admin 601x2526x1 6snh1i 80.13.147.14 /rest/nfeed/3.0/nFeed/field/input/options [c.a.a.core.auth.ApplicationLinkRequestFactoryFactoryImpl] Couldn't parse uri 'rest/api/content/search?cql=space%3DTEST%20and%20type%20%3D%20page%20and%20text%20~%20%22home*%22
            ' supplied to RequestFactory.createRequest(), assuming relative.
        2019-08-16 10:01:56,294 http-nio-8080-exec-5 ERROR admin 601x2526x1 6snh1i 80.13.147.14 /rest/nfeed/3.0/nFeed/field/input/options [c.v.j.p.s.f.rest.v3.RuntimeFieldService] Error while building input options
        java.lang.IllegalArgumentException: java.net.URISyntaxException: Illegal character in query at index 136: http://highway-star.valiantys.com:8098/rest/api/content/search?cql=space%3DTEST%20and%20type%20%3D%20page%20and%20text%20~%20%22home*%22
        
        	at com.atlassian.applinks.core.auth.ApplicationLinkRequestFactoryFactoryImpl$AbsoluteURLRequestFactory.createRequest(ApplicationLinkRequestFactoryFactoryImpl.java:178)
        	at com.valiantys.jira.plugins.sql.service.request.execution.datasource.url.applink.ApplicationLinkRequester.tryCreateRequestFactory(ApplicationLinkRequester.java:57)
        	at com.valiantys.jira.plugins.sql.service.request.execution.datasource.url.applink.ApplicationLinkRequester.createRequest(ApplicationLinkRequester.java:69)
        	at com.valiantys.jira.plugins.sql.service.request.execution.datasource.url.applink.ApplicationLinkRequester.getResponse(ApplicationLinkRequester.java:40)
        	at com.valiantys.jira.plugins.sql.service.request.execution.datasource.url.AppLinkConnection.getStream(AppLinkConnection.java:47)
        	at com.valiantys.jira.plugins.sql.service.request.execution.datasource.url.StreamConnection.getRawDatasourceResult(StreamConnection.java:37)
        	at com.valiantys.jira.plugins.sql.service.request.execution.datasource.url.StreamConnection.getRawDatasourceResult(StreamConnection.java:23)
        	at com.valiantys.jira.plugins.sql.service.request.execution.datasource.cache.DatasourceWithCacheDecorator.getRawDatasourceResult(DatasourceWithCacheDecorator.java:64)
        	at com.valiantys.jira.plugins.sql.service.request.execution.datasource.DatasourceRequestExecutor.executeDatasourceRequest(DatasourceRequestExecutor.java:45)
        	at com.valiantys.jira.plugins.sql.service.request.execution.resultset.DatasourceResultSetFactory.create(DatasourceResultSetFactory.java:32)
        	at com.valiantys.jira.plugins.sql.service.request.execution.RequestExecutionService.getInputResultSet(RequestExecutionService.java:45)
        	at com.valiantys.jira.plugins.sql.service.request.execution.RequestExecutionService.getResultSet(RequestExecutionService.java:33)
        	at com.valiantys.jira.plugins.sql.service.rendering.ResultSetRenderingService.consumeResultSet(ResultSetRenderingService.java:38)
        	at com.valiantys.jira.plugins.sql.fieldruntime.rest.v3.RuntimeFieldService.getInputOptions(RuntimeFieldService.java:259)
        	... 2 filtered
        	at java.lang.reflect.Method.invoke(Method.java:498)
        	... 19 filtered
        	at com.atlassian.plugins.rest.module.RestDelegatingServletFilter$JerseyOsgiServletContainer.doFilter(RestDelegatingServletFilter.java:159)
        	... 1 filtered
        	at com.atlassian.plugins.rest.module.RestDelegatingServletFilter.doFilter(RestDelegatingServletFilter.java:69)
        	... 32 filtered
        	at com.atlassian.servicedesk.internal.web.ExternalCustomerLockoutFilter.doFilter(ExternalCustomerLockoutFilter.java:55)
        	... 13 filtered
        	at com.atlassian.web.servlet.plugin.request.RedirectInterceptingFilter.doFilter(RedirectInterceptingFilter.java:21)
        	... 57 filtered
        	at com.atlassian.jira.security.JiraSecurityFilter.lambda$doFilter$0(JiraSecurityFilter.java:66)
        	... 1 filtered
        	at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:64)
        	... 16 filtered
        	at com.atlassian.plugins.rest.module.servlet.RestSeraphFilter.doFilter(RestSeraphFilter.java:37)
        	... 19 filtered
        	at com.atlassian.jira.servermetrics.CorrelationIdPopulatorFilter.doFilter(CorrelationIdPopulatorFilter.java:30)
        	... 5 filtered
        	at com.valiantys.jira.plugins.sql.service.servletcontext.ContextListenerServletFilter.doFilter(ContextListenerServletFilter.java:24)
        	... 3 filtered
        	at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.lambda$invokeFilterChain$0(CustomerContextSettingFilter.java:183)
        	at com.atlassian.servicedesk.internal.api.util.context.ReentrantThreadLocalBasedCodeContext.rteInvoke(ReentrantThreadLocalBasedCodeContext.java:136)
        	at com.atlassian.servicedesk.internal.api.util.context.ReentrantThreadLocalBasedCodeContext.runInContext(ReentrantThreadLocalBasedCodeContext.java:54)
        	at com.atlassian.servicedesk.internal.utils.context.CustomerContextServiceImpl.runInCustomerContext(CustomerContextServiceImpl.java:37)
        	at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.inCustomerContext(CustomerContextSettingFilter.java:167)
        	at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.doFilterImpl(CustomerContextSettingFilter.java:124)
        	at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.doFilter(CustomerContextSettingFilter.java:115)
        	... 4 filtered
        	at com.atlassian.jwt.internal.servlet.JwtAuthFilter.doFilter(JwtAuthFilter.java:37)
        	... 8 filtered
        	at com.atlassian.web.servlet.plugin.request.RedirectInterceptingFilter.doFilter(RedirectInterceptingFilter.java:21)
        	... 4 filtered
        	at com.atlassian.web.servlet.plugin.LocationCleanerFilter.doFilter(LocationCleanerFilter.java:36)
        	... 26 filtered
        	at com.atlassian.jira.servermetrics.MetricsCollectorFilter.doFilter(MetricsCollectorFilter.java:25)
        	... 25 filtered
        	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        	at java.lang.Thread.run(Thread.java:748)
        Caused by: java.net.URISyntaxException: Illegal character in query at index 136: http://highway-star.valiantys.com:8098/rest/api/content/search?cql=space%3DTEST%20and%20type%20%3D%20page%20and%20text%20~%20%22home*%22
        
        	at java.net.URI$Parser.fail(URI.java:2848)
        	at java.net.URI$Parser.checkChars(URI.java:3021)
        	at java.net.URI$Parser.parseHierarchical(URI.java:3111)
        	at java.net.URI$Parser.parse(URI.java:3053)
        	at com.atlassian.applinks.core.auth.ApplicationLinkRequestFactoryFactoryImpl$AbsoluteURLRequestFactory.createRequest(ApplicationLinkRequestFactoryFactoryImpl.java:170)
        	... 273 more
        

      Expected

      • The field behaves normally and there is no error message

      Workaround

      Remove the line breaks and spaces:

      #if($userInput.length()>0)rest/api/content/search?cql=$util.encodeURIComponent('space=TEST and type = page and text ~ "')$userInput.urlEncode()$util.encodeURIComponent('*"')#else$query.abort()#end
      

      Notes

      • Even the Configuration Tester fails: no error, but the admin page is blank:

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              nicolas.esteves@valiantys.com Nicolas Esteves
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: