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-20509] Move doCheckJobName to View #2192
Conversation
…sed also from folders.
This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation. |
} | ||
|
||
try { | ||
Jenkins.checkGoodName(value); |
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.
I have to include a similar validation in the client-side part, specifically, here.
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.
You cannot do all this validation on the client side, and there is no reason to. We already have an endpoint to do all the validation you need.
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.
client-side validations do not exclude to server-side validations.
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.
Well certainly you can do trivial client-side validation like that the field is not empty. But the detailed logic (illegal character names, Item.CREATE
permission, ProjectNamingStrategy
, existing child) would be hard to replicate on the client side, and we would wind up with a lot of duplicated code since the server already checks all this stuff before actually creating the new item.
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.
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.
But that is accomplished simply by calling checkJobName
and displaying an error message if it returns one (perhaps also disabling the submit button).
🐝 and 👍 |
Should this actually be done at the Item / TopLevelItem level? |
Not sure what you are asking. This PR is just taking an endpoint used by Now it is also possible to keep this logic in |
Let's say, for example, there's an item type for running an assembler build, it requires an old tool that breaks if spaces are in the path, in the event the Item type itself was aware of this limitation, it could prevent names being used with spaces. Obviously this wouldn't catch all scenarios. Anyway, this is probably a fairly irrelevant case. 🐝 |
No it could not, because this method is not sensitive to item type. (It could be, but that would need to be a new API in
|
@@ -35,6 +35,7 @@ | |||
import hudson.Util; | |||
import hudson.model.Descriptor.FormException; | |||
import hudson.model.labels.LabelAtomPropertyDescriptor; | |||
import hudson.model.listeners.ItemListener; |
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.
Where is being used?
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.
Javadoc
JENKINS-20509
Useless on its own because we are still awaiting a fix of JENKINS-33755 that would actually call this endpoint, but at least sets up the right backend.
@reviewbybees