Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin Failing After IntelliJ Upgrade to 0.13.15 if jenkins is hosted Tomcat or Query Parameters are not relaxed #426

Closed
fiveoaksmn opened this issue Dec 19, 2022 · 31 comments · Fixed by #435
Assignees
Labels

Comments

@fiveoaksmn
Copy link

fiveoaksmn commented Dec 19, 2022

After upgrading to 2022.3, the Jenkins plugin has stopped working. Below exception is being thrown:

Access is allowed from event dispatch thread only

com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments: EventQueue.isDispatchThread()=false
Current thread: Thread[ApplicationImpl pooled thread 63,4,main] 1748510217
SystemEventQueueThread: Thread[AWT-EventQueue-0,6,main] 1166426085
	at com.intellij.openapi.application.impl.ApplicationImpl.throwThreadAccessException(ApplicationImpl.java:1042)
	at com.intellij.openapi.application.impl.ApplicationImpl.assertIsDispatchThread(ApplicationImpl.java:1025)
	at com.intellij.ui.SpeedSearchBase.isPopupActive(SpeedSearchBase.java:180)
	at com.intellij.ui.speedSearch.SpeedSearchSupply.getSupply(SpeedSearchSupply.java:63)
	at com.intellij.ui.speedSearch.SpeedSearchSupply.getSupply(SpeedSearchSupply.java:52)
	at com.intellij.ui.speedSearch.SpeedSearchUtil.applySpeedSearchHighlightingFiltered(SpeedSearchUtil.java:185)
	at com.intellij.ui.ColoredTreeCellRenderer.rendererComponentInner(ColoredTreeCellRenderer.java:124)
	at com.intellij.ui.ColoredTreeCellRenderer.getTreeCellRendererComponent(ColoredTreeCellRenderer.java:53)
	at com.intellij.ui.tree.ui.DefaultTreeUI.getRenderer(DefaultTreeUI.java:179)
	at com.intellij.ui.tree.ui.DefaultTreeUI$2.getNodeDimensions(DefaultTreeUI.java:553)
	at java.desktop/javax.swing.tree.AbstractLayoutCache.getNodeDimensions(AbstractLayoutCache.java:497)
	at java.desktop/javax.swing.tree.VariableHeightLayoutCache$TreeStateNode.updatePreferredSize(VariableHeightLayoutCache.java:1344)
	at java.desktop/javax.swing.tree.VariableHeightLayoutCache.rebuild(VariableHeightLayoutCache.java:723)
	at java.desktop/javax.swing.tree.VariableHeightLayoutCache.treeStructureChanged(VariableHeightLayoutCache.java:629)
	at java.desktop/javax.swing.plaf.basic.BasicTreeUI$Handler.treeStructureChanged(BasicTreeUI.java:4407)
	at java.desktop/javax.swing.tree.DefaultTreeModel.fireTreeStructureChanged(DefaultTreeModel.java:616)
	at java.desktop/javax.swing.tree.DefaultTreeModel.reload(DefaultTreeModel.java:320)
	at java.desktop/javax.swing.tree.DefaultTreeModel.reload(DefaultTreeModel.java:227)
	at org.codinjutsu.tools.jenkins.JenkinsTree.clear(JenkinsTree.java:149)
	at org.codinjutsu.tools.jenkins.view.BrowserPanel.clearView(BrowserPanel.java:313)
	at org.codinjutsu.tools.jenkins.view.BrowserPanel.setJobsUnavailable(BrowserPanel.java:308)
	at org.codinjutsu.tools.jenkins.view.BrowserPanel.handleEmptyConfiguration(BrowserPanel.java:304)
	at org.codinjutsu.tools.jenkins.logic.BrowserPanelAuthenticationHandler.loginCancelled(BrowserPanelAuthenticationHandler.java:42)
	at com.intellij.util.messages.impl.MessageBusImplKt.invokeMethod(MessageBusImpl.kt:652)
	at com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:621)
	at com.intellij.util.messages.impl.MessageBusImplKt.deliverMessage(MessageBusImpl.kt:395)
	at com.intellij.util.messages.impl.MessageBusImplKt.pumpWaiting(MessageBusImpl.kt:374)
	at com.intellij.util.messages.impl.MessageBusImplKt.access$pumpWaiting(MessageBusImpl.kt:1)
	at com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:433)
	at jdk.proxy13/jdk.proxy13.$Proxy240.loginCancelled(Unknown Source)
	at org.codinjutsu.tools.jenkins.logic.LoginService$1.run(LoginService.java:45)
	at org.codinjutsu.tools.jenkins.logic.JenkinsBackgroundTask.run(JenkinsBackgroundTask.java:41)
	at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:425)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:114)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsynchronously$6(CoreProgressManager.java:476)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:252)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:190)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:591)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:666)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:622)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:590)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:177)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:252)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
	at java.base/java.lang.Thread.run(Thread.java:833)

If I go into the preferences for the plugin and click Test Connection, it responds with: [Fail] URL is malformed.

The URL is correct however. I can copy and paste it into a browser and it works just fine.

@MCMicS
Copy link
Owner

MCMicS commented Dec 20, 2022

@cfpfeiff
Copy link

Can you please use following: https://plugins.jetbrains.com/plugin/6110-jenkins-control/versions/eap/263516

Works for me! Thanks! 😄

@MCMicS
Copy link
Owner

MCMicS commented Dec 20, 2022

nice to hear
I will it release this version at start of new year

@MCMicS MCMicS closed this as completed Dec 20, 2022
@fiveoaksmn
Copy link
Author

I installed the version reference above but it is still failing for me. Not getting the exception anymore but the plugin is still saying malformed URL in the preferences and none of the tasks will load. I do have a port in my URL. Could that be making a difference?

e.g. http://127.0.0.1:8080/jenkins/

@MCMicS
Copy link
Owner

MCMicS commented Dec 21, 2022

No the port is no problem. Maybe another error or redirect for your server

Can you do a curl call to test it?

curl -v -u user:token https://jenkins-xxx-xxx-dev.apps.xy01.ddd.x-internal.com/api/json?tree=nodeName,url,description,primaryView%5Bname%2Curl%5D

@MCMicS MCMicS reopened this Dec 21, 2022
@fiveoaksmn
Copy link
Author

fiveoaksmn commented Dec 21, 2022 via email

@MCMicS
Copy link
Owner

MCMicS commented Dec 21, 2022

Do you use any proxies?
Is there any additional hint in log file?

I can build you a own version with additional logs in new year.

@fiveoaksmn
Copy link
Author

fiveoaksmn commented Dec 21, 2022 via email

@MCMicS
Copy link
Owner

MCMicS commented Dec 21, 2022

I will test again.
Is your server public visible or it is possible to grant access to me for test

In latest plugin version I switched the used http client implementation. Have yo tested the same plugin version with older idea version too?

@fiveoaksmn
Copy link
Author

fiveoaksmn commented Dec 21, 2022 via email

@fiveoaksmn
Copy link
Author

fiveoaksmn commented Dec 22, 2022 via email

@MCMicS
Copy link
Owner

MCMicS commented Dec 22, 2022

Thanks
i will investigate it.
In my setups with different jenkins server it still works

I will extend the loggging to find the problem

Maybe a problem with url with path part

But it will on start of next year. Sorry

@MCMicS
Copy link
Owner

MCMicS commented Jan 2, 2023

Could you please try following buiid. and try

And enable Debug settings if error still occurs (enable for org.codinjutsu.tools.jenkins). Then in ida.log should exists the reason.
grafik

My Settings:
grafik

Plugin: jenkins-control-plugin-0.13.16-eap3-2022.2.zip

@fiveoaksmn
Copy link
Author

fiveoaksmn commented Jan 2, 2023 via email

@MCMicS
Copy link
Owner

MCMicS commented Jan 2, 2023

it says java.net.MalformedURLException: no protocol:

Why the the protocol is missing.

The jenkins server seem not to return a valid url

Please use curl:
curl -u user:token http://127.0.0.1:8080/jenkins/api/json?tree=nodeName,url,description,primaryView%5Bname,url%5D

the JSOn result should looks like:

{"_class":"hudson.model.Hudson","nodeName":"","description":null,"primaryView":{"_class":"hudson.model.AllView","name":"all","url":"http://127.0.0.1:8080/jenkins/"},"url":"http://127.0.0.1:8080/jenkins/"}

I suggest that the primary View or url is empty

@MCMicS
Copy link
Owner

MCMicS commented Jan 2, 2023

I could reproduce it with following steps:
grafik

  1. Clear Jenkins URL and click save
  2. Then the JSON result contains the nullvalue
  3. click refresh (F5 or Ctrl/Cmd+R) and the default URL is filled in the text. Then save theses values
  4. JSON should contains the correct url

I saw this time ago too (missing url) due wrong saving server settings within jenkins

@MCMicS
Copy link
Owner

MCMicS commented Jan 2, 2023

I've created another version with improved url handling. I use primary view now correct as fallback

jenkins-control-plugin-0.13.16-eap3-2022.2.zip

Can you please test it?
sorry for the circumstances

@fiveoaksmn
Copy link
Author

fiveoaksmn commented Jan 3, 2023 via email

@MCMicS
Copy link
Owner

MCMicS commented Jan 3, 2023

The message Cannot find 'Jenkins URL'. Please check your Jenkins location is my new one if no url is found.

Can you please send me your json result for the curl command.
curl -v -u user:token http://127.0.0.1:8080/jenkins/api/json?tree=nodeName,url,description,primaryView%5Bname,url%5D

Have you tried to to set the server url in 'manage jenkins' again?

The logic was not changed in last release. Have you changed any setting in Jenkins itself or updated it?
If you use an olden Jenkins Control Plugin the connection works on the same server or it is failing too?

The error Empty JSON data sometimes happen currently. Mostly if server is restareted or other scenarios
Can you also check and send the json result for:
http://127.0.0.1:8080/jenkins/api/json?tree=url,description,nodeName,nodeDescription,primaryView%5Bname,url%5D,views%5Bname,url,views%5Bname,url%5D%5D

Instead curl you can alos copy these urlls to browser to see see the json result. but curl can provide more data with option -v

@fiveoaksmn
Copy link
Author

Here is the output from curl:

*   Trying 127.0.0.1:8080...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
* Server auth using Basic with user 'grant'
> GET /jenkins/api/json?tree=nodeName,url,description,primaryView%5Bname,url%5D HTTP/1.1
> Host: 127.0.0.1:8080
> Authorization: Basic Z3JhbnQ6MTFlNjA4N2FhNjEyMjg4MDY2OTViZWM5NmQzN2U4M2RhMw==
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200
< Cache-Control: private
< X-Content-Type-Options: nosniff
< X-Jenkins: 2.361.2
< X-Jenkins-Session: e78c5abb
< X-Frame-Options: deny
< Content-Type: application/json;charset=UTF-8
< Content-Length: 208
< Date: Wed, 04 Jan 2023 06:30:00 GMT
<
* Connection #0 to host 127.0.0.1 left intact
{"_class":"hudson.model.Hudson","nodeName":"","description":null,"primaryView":{"_class":"hudson.model.AllView","name":"all","url":"http://acorn.local:8080/jenkins/"},"url":"http://acorn.local:8080/jenkins/"}

I went into Jenkins and I reset the Jenkins URL. Didn't fix anything.

I'll download to an older version of the plugin tomorrow and see what happens and let you know.

@MCMicS
Copy link
Owner

MCMicS commented Jan 4, 2023

Looks fine on first view
but I will look further the day

@MCMicS
Copy link
Owner

MCMicS commented Jan 4, 2023

The only difference in our curl result and mine is the Header Cache-Control: private.

Your Url says http://acorn.local:8080. Is it a local installation.
It is possible to share the jenkins configraution (zip of JENKINS_HOME)? I can also provide a space to upload for private data.

I also add additional debug logs to print out the received JSON data. Maybe I receive an Http status which I not handle correctly (like use cached values). Please set following log configuration:

org.codinjutsu.tools.jenkins
#org.codinjutsu.tools.jenkins:trace

You will then see following in idea.log

o.c.t.j.s.BasicSecurityClient - Call url 'http://127.0.0.1:8080/jenkins/api/json?tree=nodeName,url,description,primaryView[name,url]' --> Status: 200, Data {"_class":"hudson.model.Hudson","nodeName":"","description":null,"primaryView":{"_class":"hudson.model.AllView","name":"all","url":"http://127.0.0.1:8080/jenkins/"},"url":null}

But make sure to remve the :trace entry or your log will be large.

With more logs:
jenkins-control-plugin-0.13.16-eap3-2022.2-signed.zip

@MCMicS
Copy link
Owner

MCMicS commented Jan 6, 2023

Hi @fiveoaksmn
have you got time to test it?

@fiveoaksmn
Copy link
Author

fiveoaksmn commented Jan 6, 2023 via email

@MCMicS
Copy link
Owner

MCMicS commented Jan 6, 2023

no problem. thanks for testing

@fiveoaksmn
Copy link
Author

Here is what is found in the IntelliJ log:

2023-01-06 16:14:54,273 [ 157804]  FINER - #org.codinjutsu.tools.jenkins.security.BasicSecurityClient - Call url 'http://acorn.local:8080/jenkins/api/json?tree=nodeName,url,description,primaryView[name,url]' --> Status: 400, Data <!doctype html><html lang="en"><head><title>HTTP Status 400 – Bad Request</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {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 [&#47;jenkins&#47;api&#47;json?tree=nodeName,url,description,primaryView[name,url] ]. The valid characters are defined in RFC 7230 and RFC 3986</p><p><b>Description</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 [&#47;jenkins&#47;api&#47;json?tree=nodeName,url,description,primaryView[name,url] ]. The valid characters are defined in RFC 7230 and RFC 3986
	org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:509)
	org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:513)
	org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:882)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1693)
	org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
	org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	java.base&#47;java.lang.Thread.run(Thread.java:829)

@MCMicS
Copy link
Owner

MCMicS commented Jan 6, 2023

Thanks for it
I have an idea what is the problem. It seems that your server not allow the square brackets. I will encode this tomorrow and provide you a new version for test.

have you configured your jenkins serve in special way?

I tested with simply war file and started it. But then the appi calls works.
maybe you can share your jetty or server settings

@MCMicS
Copy link
Owner

MCMicS commented Jan 6, 2023

Can you please test again following build:
jenkins-control-plugin-0.13.16-eap3-2022.2-signed.zip

Do you use jetty for your Jenkins or have you deployed it in other application server like tomcat?

@fiveoaksmn
Copy link
Author

It works! Did you just end up changing the encoding of the URL?

I am using Tomcat to host Jenkins. Nothing is configured outside the box.

I appreciate your efforts in debugging this and updating the plugin.

@MCMicS
Copy link
Owner

MCMicS commented Jan 7, 2023

Yes I encoded the query parameter
I use a built-in URLUtil to encode but then square brackets was not encoded. With jetty it was no problem. In Tomcat it has to be configured with relaxedQueryChars

now I encode it again with another URLEncoder and it works again

I will build a release asap

Thanks for testing and sorry for the circumstances

@MCMicS MCMicS added the bug label Jan 7, 2023
@MCMicS MCMicS self-assigned this Jan 7, 2023
@MCMicS MCMicS changed the title Plugin Failing After IntelliJ Upgrade Plugin Failing After IntelliJ Upgrade to 0.13.15 if jenkins is hosted Tomcat or QUery Parameters are not relaxed Jan 11, 2023
@MCMicS MCMicS changed the title Plugin Failing After IntelliJ Upgrade to 0.13.15 if jenkins is hosted Tomcat or QUery Parameters are not relaxed Plugin Failing After IntelliJ Upgrade to 0.13.15 if jenkins is hosted Tomcat or Query Parameters are not relaxed Jan 16, 2023
@MCMicS
Copy link
Owner

MCMicS commented Jan 16, 2023

released with 0.13.16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants