-
Improvement
-
Resolution: Fixed
-
Major
-
None
-
http_request:1.8.22
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:
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