-
Notifications
You must be signed in to change notification settings - Fork 396
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
[JENKINS-60738] Fix global configuration submission from UI #347
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, manually tested and is working 🙂
While this sounds fine as a hotfix, the proper fix would be to delete all the overrides and special cases handling and fix the form to use normal databinding by convention. |
f.entry(title: _("Override Hook URL")) { | ||
g.blockWrapper { | ||
f.optionalBlock(title: _("Specify another hook URL for GitHub configuration"), | ||
name: "isOverrideHookUrl", | ||
inline: true, | ||
checked: instance.isOverrideHookUrl()) { | ||
f.entry(field: "hookUrl") { | ||
f.textbox(checkMethod: "post") | ||
f.textbox(checkMethod: "post", name: "hookUrl") | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example all of this should just be like
<f:entry field="hookUrl">
<f:textbox label="Alternate hook URL for GitHub configuration"/>
</f:entry>
which may be blank.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see. Remove all the optional block that is not necessary.. Yeah sounds good to me I can test this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be more work for sure. The usual problem with this sort of fix is retaining compatibility for both XML settings and JCasC. Sometimes hacking up the JSON processing in the GUI logic is the only option since refactoring to a simpler structure would break something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the thing that bother me is the type URL
of the hookUrl
... Because of that type, the value cannot actually be blank :( :
java.net.MalformedURLException: no protocol:
at java.base/java.net.URL.<init>(URL.java:645)
at java.base/java.net.URL.<init>(URL.java:541)
at java.base/java.net.URL.<init>(URL.java:488)
at org.kohsuke.stapler.Stapler$3.convert(Stapler.java:1141)
Caused: org.apache.commons.beanutils.ConversionException: no protocol:
So it is not that simple to "reset" the hook URL because of the binding.. I thought about changing the type from URL
to String
but the existing public getter might be a problem: https://github.com/jenkinsci/github-plugin/blob/master/src/main/java/org/jenkinsci/plugins/github/config/GitHubPluginConfig.java#L131-L141
Changing its signature could be a breaking change. Though it does not seem to be used outside the scope of that plugin repo: https://github.com/search?ref=simplesearch&type=code&q=user%3Ajenkinsci++getHookUrl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW use permalinks for better display:
github-plugin/src/main/java/org/jenkinsci/plugins/github/config/GitHubPluginConfig.java
Lines 131 to 141 in 47b623a
/** | |
* @return hook url used as endpoint to search and write auto-managed hooks in GH | |
* @throws GHPluginConfigException if default jenkins url is malformed | |
*/ | |
public URL getHookUrl() throws GHPluginConfigException { | |
if (hookUrl != null) { | |
return hookUrl; | |
} else { | |
return constructDefaultUrl(); | |
} | |
} |
setHookUrl(null); | ||
} | ||
req.bindJSON(this, json); | ||
clearRedundantCaches(configs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than this method call, the whole configure
method should not even need to be overridden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only way I found to simplify the data-binding and just do a req.bindJson
is to change the signature of public URL getHookUrl()
to public String getHookUrl()
. That could be a breaking change. Example at 77cfb02.
So not sure if that would be acceptable ? cc @KostyaSha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better ask @jglick i forgot databinding nuances
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That could be a breaking change. … So not sure if that would be acceptable ?
https://github.com/search?q=org%3Ajenkinsci%20getHookUrl&type=code does not look like it is used from other plugins.
@KostyaSha are you ok with this as the active maintainer of this plugin? |
What's the status of this? I've just run into this with our own instance. |
I have the same issue; as a workaround I've been adding |
If you edit the config file and restart so it has the updated value in memory then the UI should show the correct setting and not clobber it on save. |
Can this be merged soon? I've just noticed this open PR after implementing the same fix and opening another PR : #375 Feel free to close the other PR |
(I am not a maintainer) |
@jenkinsci/github-plugin-developers anybody able to merge this ? |
@KostyaSha perhaps |
Fixes JENKINS-60738 caused by changes introduced in #221.
Databinding of
hookUrl
is not working properly, per my understanding because theDataboundSetter
setHookUrl(String hookUrl) accepts aString
but the field is aURL
. While adding apublic void setHookUrl(URL hookUrl)
might solve some of the problem, then there is yet another issue that disabling the Specify another hook URL for GitHub configuration checkbox does not remove the hook URL at all... that seems wrong.So the propose fix:
configure(StaplerRequest req, JSONObject json)