1
Solved

Jenkins returns 400 when Catlight tries to fetch jobs tree

When Catlight tries to send "GET https://my-jenkins:11001/jenkins/api/json?tree=jobs[name,displayName,url,buildable,jobs[name,displayName,url..."  at the very begining of configuring a Jenkins connection, Jenkins reponds with 400 saying complaining about Invalid Characters in request. It seems that Catlight does not escape the query parameter "tree" properly. By issuing the same request manually with the query parameter encoded properly Jenkins responds with 200 and correct payload.

The extract from NetworkLog:

2020-02-18 14:41:02.7613 | TRACE | NetworkLog | 76 | =========================================
GET https://my-jenkins:11001/jenkins/api/json?tree=jobs[name,displayName,url,buildable,jobs[name,displayName,url,buildable,jobs[name,displayName,url,buildable,jobs[name,displayName,url,buildable,jobs[name,displayName,url,buildable,jobs[name,displayName,url,buildable]]]]]]
User-Agent : Catlight/2.29.1
Accept : application/json
Authorization : *****

400 BadRequest
Connection : close
Date : Tue, 18 Feb 2020 14:41:02 GMT
<!doctype html><html lang="de"><head><title>HTTP Status 400 – Bad Request</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 400 – Bad Request</h1><hr class="line" /><p><b>Type</b> Exception Report</p><p><b>Message</b> Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986</p><p><b>Bescrheibung</b> The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).</p><p><b>Exception</b></p><pre>java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:467)
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:294)
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:836)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1747)
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:748)
</pre><p><b>Hinweis</b> Der komplette Stacktrace der Ursache ist in den Server logs zu finden</p><hr class="line" /></body></html>

Extract from log:

2020-02-18 14:41:02.7613 | WARN | Catlight.Service.Common.ApiErrorHandlingMiddleware | 76 | API exception System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 ().
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Web.Services.Jenkins.JenkinsAdapter.EnsureResponseSuccess(HttpResponseMessage response) in C:\build\1\_work\4\s\Desktop\LocalWeb\Services\Jenkins\JenkinsAdapter.cs:line 845
at Web.Services.Jenkins.JenkinsAdapter.ApiGet[T](String uri, JenkinsConnectionSettings settings) in C:\build\1\_work\4\s\Desktop\LocalWeb\Services\Jenkins\JenkinsAdapter.cs:line 831
at Web.Services.Jenkins.JenkinsAdapter.GetMetadata(CancellationToken cancellationToken) in C:\build\1\_work\4\s\Desktop\LocalWeb\Services\Jenkins\JenkinsAdapter.cs:line 93
at Web.Services.Builds.ServerAdapterPoller.UpdateServerMetadata() in C:\build\1\_work\4\s\Desktop\LocalWeb\Services\Builds\ServerAdapterPoller.cs:line 296
at Web.Services.ServerManager.GetMonitoringSettings(Boolean forceRefresh) in C:\build\1\_work\4\s\Desktop\LocalWeb\Services\ServerManager.cs:line 191
at Web.Controllers.ServersController.GetMonitoringSettings(Guid instanceId, Boolean forceRefresh) in C:\build\1\_work\4\s\Desktop\LocalWeb\Controllers\ServersController.cs:line 144
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.Invoke(HttpContext context)
at Catlight.Service.Common.ApiErrorHandlingMiddleware.Invoke(HttpContext context) in C:\build\1\_work\4\s\Catlight.Service.Common\ApiErrorHandlingMiddleware.cs:line 49

2 replies

SU

Catlight version 2.29.1 for Windows

SU

Jenkins version 2.190.2

Thanks for reporting the problem! It should be fixed in 2.29.2 - https://catlight.io/downloads