Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-57318

validResponseCodes cannot be empty or null

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Component/s: http-request-plugin
    • Labels:
      None
    • Environment:
      http_request:1.8.22
    • Similar Issues:

      Description

      For the `httpRequest` function, the parameter `validResponseCodes` is described as optional here: https://jenkins.io/doc/pipeline/steps/http_request/

      It would be great if it allowed passing an empty or null string. Doing so currently causes an error in the `parseToRange` method:

      Empty string:

      ```
      08:28:19 java.lang.IllegalArgumentException: Invalid number 08:28:19 at jenkins.plugins.http_request.HttpRequest$DescriptorImpl.parseToRange(HttpRequest.java:419)08:28:19 at jenkins.plugins.http_request.HttpRequestExecution.responseCodeIsValid(HttpRequestExecution.java:299)08:28:19 at jenkins.plugins.http_request.HttpRequestExecution.processResponse(HttpRequestExecution.java:316)08:28:19 at jenkins.plugins.http_request.HttpRequestExecution.authAndRequest(HttpRequestExecution.java:232)08:28:19 at jenkins.plugins.http_request.HttpRequestExecution.call(HttpRequestExecution.java:195)08:28:19 at jenkins.plugins.http_request.HttpRequestExecution.call(HttpRequestExecution.java:67)
      ```

       

      Null value:

      ```
      08:29:02 java.lang.NullPointerException*08:29:02* at jenkins.plugins.http_request.HttpRequest$DescriptorImpl.parseToRange(HttpRequest.java:410)08:29:02 at jenkins.plugins.http_request.HttpRequestExecution.responseCodeIsValid(HttpRequestExecution.java:299)08:29:02 at jenkins.plugins.http_request.HttpRequestExecution.processResponse(HttpRequestExecution.java:316)08:29:02 at jenkins.plugins.http_request.HttpRequestExecution.authAndRequest(HttpRequestExecution.java:232)08:29:02 at jenkins.plugins.http_request.HttpRequestExecution.call(HttpRequestExecution.java:195)08:29:02 at jenkins.plugins.http_request.HttpRequestExecution.call(HttpRequestExecution.java:67)
      ```

       

      The relevant class is here:

      https://github.com/jenkinsci/http-request-plugin/blob/master/src/main/java/jenkins/plugins/http_request/HttpRequest.java

       

      It would also be of great help if `validResponseCodes` was documented with examples on the https://jenkins.io/doc/pipeline/steps/http_request/ page. So that users do not have to go to the source code to figure out that it is a comma-separated string of ranges, for example:

      • '200' to only accept 200
      • '201,300:304' to accept 201 plus 300 to 304

        Attachments

          Activity

          Show
          therealmartinmosegaard Martin Mosegaard Amdisen added a comment - Proposed fix:  https://github.com/jenkinsci/http-request-plugin/pull/38

            People

            Assignee:
            janario Janario Oliveira
            Reporter:
            therealmartinmosegaard Martin Mosegaard Amdisen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: