Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-64651

Broken form validation with stapler

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • core
    • None

      There is an issue with stapler form validation under some specific circumstances.
      See the attached sample plugin. To reproduce the issue:

      1. Run the plugin with `mvn hpi:run`
      2. Create a new item, select "TestItem"
      3. Initial value of "Executors" is 0, even when `default` is set to 1
      4. Try change the value to any positive number, move focus out of the field to trigger a validation
      5. Nothing happens, validation message is still there.

      I haven't been able to identify the root cause, but I've reproduced some interesting behaviours locally:

      1. In the sample code, if I remove the line `<j:set var="descriptor" value="${it.descriptor}" />` then it works fine (it also works fine if the var name is set something different than `descriptor`) UPDATE: this makes it work because the backend validation is disabled with this (there isn't a descriptor by default so backend `doCheck****` is not called, so only front end validation is in place, which makes it work.

      Or:

      1. The sample plugin has validation for `numExecutors` on both frontend (using `class="positive-number"` and backend using a `doCheckNumExecutors` method in the descriptor). If one of the validation is removed (either front or back) then it works fine too.

      BTW, this was working fine in older versions of core (2.263 at least).

            fqueiruga Félix Queiruga Balado
            amuniz Antonio Muñiz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: