jenkinsci / jenkinsci/java-client-api

Job.build(Map<String, String> params) results in HTTP 414 (URI too long)

Open
#352 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
913
Forks
466
PR merge metrics
No merged PRs in 30d

Description

I've had problems with requests for a parameterized job build:

```
org.apache.http.client.HttpResponseException: Request-URI Too Long
at com.offbytwo.jenkins.client.validator.HttpResponseValidator.validateResponse(HttpResponseValidator.java:11)
at com.offbytwo.jenkins.client.JenkinsHttpClient.post(JenkinsHttpClient.java:232)
at com.offbytwo.jenkins.model.Job.build(Job.java:125)
at com.offbytwo.jenkins.model.Job.build(Job.java:112)
```

Looking at the code, I noticed that `Job.build` encodes the job parameter/values in the URL.
This can result in a very long URL that exceeds the server's max URL size.

I worked around this problem outside of the library by submitting a POST request where the job parameter/values are passed as form data instead of encoded in the url.

Contributor guide

Open the contributing guide

Research direction

Start in Job.java at the parameterized Job.build overloads and follow the request into JenkinsHttpClient.post. Check how parameter names and values are currently encoded, then compare that with the reported form-data workaround. Done means parameterized builds use a request representation that avoids HTTP 414 for long values while preserving the parameters.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.