regression issue with Redirects

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor
    • Component/s: http-request-plugin
    • None
    • Environment:
      Jenkins 2.528.1
      http plugin 1.22

      We have a problem with one request that has changed in the result between 1.20 and 1.22.
      Unfortunately I was not able to identify the exact problem yet.
      The use case is that we are using the JCasC Endpoint to roll out JCasC on our instance. For AuthN/AuthZ I am using my account - which is Admin and an generated API token as password.
      We have stored the JCasC yaml on an Azure Storage Account and apply the code via

              stage('replace') {
                  steps {
                      script {
                          def config = configJenkins()
                          def storageUrl = "https://${config.sta}.blob.core.windows.net/${config.container}/clouds-${STAGE}.yaml?${AGENT_SEED_ACCESS_TOKEN}"
                          def encodedStorageUrl = URLEncoder.encode(storageUrl, 'UTF-8')
                          def rest = "https://${DEVTOOLS_JENKINS_MASTER}.airplus.net/configuration-as-code/replace?_.newSource=${encodedStorageUrl}"
                          def response = httpRequest consoleLogResponseBody: true,
                          ignoreSslErrors: true,
                          customHeaders:[
                              [name:'Authorization', value:"Basic ${auth}"]
                          ],
                          httpMode: 'POST',
                          url: rest
      
                          echo "${response}"
                      }
                  }
              }
      

      the ${auth} is created with

             stage('Init') {
                  steps {
                      script {
                          wrap([$class: 'BuildUser']) {
                              def user = User.get(env.BUILD_USER_ID, false)
                              def apiTokenProperty = user.getProperty(ApiTokenProperty.class)
                              def token = apiTokenProperty.tokenStore.tokenListSortedByName.find{ t -> t.name == 'cloud-seed'}
                              if(token) {
                                  apiTokenProperty.tokenStore.revokeToken(token.uuid)
                              }
                              def secret = apiTokenProperty.tokenStore.generateNewToken('cloud-seed').plainValue
                              def creds = "${user}:${secret}"
      
                              auth = creds.bytes.encodeBase64().toString()
      
                          }
      
                      }
                  }
              }
      

      When running the pipeline with http clien <= 1.20 we get:

      18:38:30  HttpMethod: POST
      18:38:30  URL: https://XXX/configuration-as-code/checkNewSource?newSource=https%3A%2F%2FYYY.blob.core.windows.net%2Fjenkins%2Fclouds-NONLIVE.yaml...
      18:38:30  Authorization: *****
      18:38:31  Sending request to url: https://XXX/configuration-as-code/checkNewSource?newSource=https%3A%2F%2FYYY.blob.core.windows.net%2Fjenkins%2Fclouds-NONLIVE.yaml...
      18:38:31  Response Code: HTTP/1.1 200 OK
      18:38:31  Response: 
      18:38:31  <div class="ok">The configuration can be applied</div>
      18:38:31  Success: Status code 200 is in the accepted range: 100:399
      18:38:32  Status: 200
      18:38:32  HttpMethod: POST
      18:38:32  URL: https://XXX/configuration-as-code/checkNewSource?newSource=https%3A%2F%2FYYY.blob.core.windows.net%2Fjenkins%2Fclouds-NONLIVE.yaml...
      18:38:32  Authorization: *****
      18:38:32  Sending request to url: https://XXX/configuration-as-code/checkNewSource?newSource=https%3A%2F%2FYYY.blob.core.windows.net%2Fjenkins%2Fclouds-NONLIVE.yaml...
      18:38:33  Response Code: HTTP/1.1 302 Found
      18:38:33  Response: 
      18:38:33  
      18:38:33  Success: Status code 302 is in the accepted range: 100:399
      18:38:33  Status: 302
      

      With http client 1.22 we now get:

      16:20:34  HttpMethod: POST
      16:20:34  URL: https://XXX/configuration-as-code/checkNewSource?newSource=https%3A%2F%2FYYY.blob.core.windows.net%2Fjenkins%2Fclouds-NONLIVE.yaml...
      16:20:34  Authorization: *****
      16:20:34  Sending request to url: https://XXX/configuration-as-code/checkNewSource?newSource=https%3A%2F%2FYYY.blob.core.windows.net%2Fjenkins%2Fclouds-NONLIVE.yaml...
      16:20:36  Response Code: 403
      16:20:36  Response: 
      16:20:36  <html><head><meta http-equiv='refresh' content='1;url=/login?from=%2Fconfiguration-as-code%2F'/><script id='redirect' data-redirect-url='/login?from=%2Fconfiguration-as-code%2F' src='/static/8a6427b2/scripts/redirect.js'></script></head><body style='background-color:white; color:white;'>
      16:20:36  Authentication required
      16:20:36  <!--
      16:20:36  -->
      16:20:36  
      16:20:36  </body></html>                                                                                                                                                                                                                                                                                                            
      hudson.AbortException: Fail: Status code 403 is not in the accepted range: 100:399 while calling https://XXX/configuration-as-code/checkNewSource?newSource=https%3A%2F%2FYYY.blob.core.windows.net%2Fjenkins%2Fclouds-NONLIVE.yaml...
      	at PluginClassLoader for http_request//jenkins.plugins.http_request.HttpRequestExecution.responseCodeIsValid(HttpRequestExecution.java:490)
      	at PluginClassLoader for http_request//jenkins.plugins.http_request.HttpRequestExecution.processResponse(HttpRequestExecution.java:500)
      	at PluginClassLoader for http_request//jenkins.plugins.http_request.HttpRequestExecution.authAndRequest(HttpRequestExecution.java:383)
      	at PluginClassLoader for http_request//jenkins.plugins.http_request.HttpRequestExecution.call(HttpRequestExecution.java:292)
      

      Because of the 403 I suspect something with the AuthN/AuthZ.

      After the occurrence of the problem and some analyzing, I reverted the http plugin back to 1.20 and our http call was working again.

      Can anybody point me on how to debug/analyse the issue?

      Thanks in advance,
      Rainer

            Assignee:
            Janario Oliveira
            Reporter:
            Rainer Montag
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: