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

Active choice parameter filter throws JavaScript error for parameter change event in browser console

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • active-choices-plugin
    • None
    • Jenkins 2.462.3
      Active Choices Plugin 2.8.4
      JDK 17
      Chrome/Edge browsers

      Use Case:

      • Pipeline
      • Active choice single select with filter parameter - paramA
      • Active reactive choice parameter - paramB that dispays options based on paramA
      • Filter paramA

       

      Expected results:

      Typing in filter of paramA, expect paramB to update its options based on the selected value in paramA dropdown.

       

      Actual results:

      paramB not updated (see attachments) and browser dev tools shows JS error (see attachments).

       

      Additional notes:

      • Manually selecting a new option in paramA dropdown works just fine.
      • Filtering down to one option does not allow manual selection since it is already selected.

       

      Test pipeline:

      #!groovy
      
      properties([
          parameters([
              [
                  $class: 'ChoiceParameter',
                  choiceType: 'PT_SINGLE_SELECT',
                  description: 'Choose opion',
                  filterLength: 1,
                  filterable: true,
                  name: 'paramA',
                  script: [
                      $class: 'GroovyScript',
                      script: [
                          classpath: [],
                          sandbox: true,
                          script: 'return ["AAA","BBB","CCC"]'
                      ],
                      fallbackScript: [
                          classpath: [],
                          sandbox: true,
                          script: 'return["ERROR paramA"]'
                      ]
                  ]
              ],
              [
                  $class: 'CascadeChoiceParameter',
                  choiceType: 'PT_RADIO',
                  description: 'chose related option',
                  filterLength: 1,
                  filterable: false,
                  name: 'paramB',
                  referencedParameters: 'paramA',
                  script: [
                      $class: 'GroovyScript',
                      script: [
                          classpath: [],
                          sandbox: true,
                          script: '''
                              if (paramA.equals("AAA")) {
                                  return ["AAA-1","AAA-2","AAA-3"]
                              }
                              else if (paramA.equals("BBB")) {
                                  return ["BBB-1","BBB-2","BBB-3"]
                              }
                              else if (paramA.equals("CCC")) {
                                  return ["CCC-1","CCC-2","CCC-3"]
                              }
                              else {
                                  return ["UNK"]
                              }
                          '''
                      ],
                      fallbackScript: [
                          classpath: [],
                          sandbox: true,
                          script: 'return["ERROR paramB"]'
                      ]
                  ]
              ]
          ])
      ])
      
      pipeline {
          agent any
      
          stages {
              stage('Params') {
                  steps {
                      echo "paramA: ${params.paramA}"
                      echo "paramB: ${params.paramB}"
                  }
              }
          }
      }
      

          [JENKINS-74967] Active choice parameter filter throws JavaScript error for parameter change event in browser console

          K added a comment - - edited

          If you type in a console

          var $ = jQuery

          it works perfect. My guess is that `UnoChoice` uses an undefined `$` alias for jQuery

          K added a comment - - edited If you type in a console var $ = jQuery it works perfect. My guess is that `UnoChoice` uses an undefined `$` alias for jQuery

          Oguz added a comment -

          Hi, 
          I can confirm that same issue in freestyle jobs with Jenkins 2.462.3

          Oguz added a comment - Hi,  I can confirm that same issue in freestyle jobs with Jenkins 2.462.3

          Thanks all for confirming! I saved JENKINS-74967 and JENKINS-73935 both to work on this weekend but had an unexpected issue on my laptop. Will try to repair it and see if I can update it before/by xmas.

          Bruno P. Kinoshita added a comment - Thanks all for confirming! I saved JENKINS-74967 and JENKINS-73935 both to work on this weekend but had an unexpected issue on my laptop. Will try to repair it and see if I can update it before/by xmas.

          Carsten L added a comment -

          Same issue here.
          JAVA 21
          Jenkins 2.479.1
          Active Choice: 2.8.6

          Current solution: Downgrade Active Choice to 2.8.3

          Carsten L added a comment - Same issue here. JAVA 21 Jenkins 2.479.1 Active Choice: 2.8.6 Current solution: Downgrade Active Choice to 2.8.3

          Logn added a comment -

          me too

          Current solution: Downgrade Active Choice to 2.8.3

          Logn added a comment - me too Current solution: Downgrade Active Choice to 2.8.3

          Bruno P. Kinoshita added a comment - - edited

          Hi chamacs , all,

          Thanks a lot for the pipeline example, and for screenshots and the other comments left with environments and confirmations of the issue.

          I'm using the latest code from `master` to try to reproduce as, even though it's not 2.8.6 tag, there were only dependabot updates, and another update done to match API changes in Jenkins & Java that affect plugins - https://github.com/jenkinsci/active-choices-plugin/blob/master/CHANGES.md#version-287-202

          I created a Pipeline job, and ran it getting the error ParamB. But the Freestyle build worked fine. I'll attach the config.xml as config-working-bruno-2.8.7-snapshot-1.xml, as well as a screenshot of my configuration page, so others can have a look to see if I'm missing anything to reproduce this issue in a freestyle job (easier to debug).

          I also remember some time ago there were changes in how Jenkins handles JQuery (I think the JQuery dependency was removed from Jenkins, so all plug-ins updated to have a dependency to JQuery plug-in, and call it a bit different). I have JQuery API Plugin 3.7.1-2, which is a dependency of the plug-in. Could anyone confirm they have this issue even though they also have the JQuery API Plug-in, please? Just so we rule out that as the possible root cause.

          Thanks!

           

          Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
          Maven home: /opt/apache-maven-3.9.9
          Java version: 17.0.13, vendor: Ubuntu, runtime: /usr/lib/jvm/java-17-openjdk-amd64
          Default locale: en_US, platform encoding: UTF-8
          OS name: "linux", version: "6.8.0-52-generic", arch: "amd64", family: "unix"

           

           

          Bruno P. Kinoshita added a comment - - edited Hi chamacs , all, Thanks a lot for the pipeline example, and for screenshots and the other comments left with environments and confirmations of the issue. I'm using the latest code from `master` to try to reproduce as, even though it's not 2.8.6 tag, there were only dependabot updates, and another update done to match API changes in Jenkins & Java that affect plugins - https://github.com/jenkinsci/active-choices-plugin/blob/master/CHANGES.md#version-287-202 I created a Pipeline job, and ran it getting the error ParamB. But the Freestyle build worked fine. I'll attach the config.xml as config-working-bruno-2.8.7-snapshot-1.xml, as well as a screenshot of my configuration page, so others can have a look to see if I'm missing anything to reproduce this issue in a freestyle job (easier to debug). I also remember some time ago there were changes in how Jenkins handles JQuery (I think the JQuery dependency was removed from Jenkins, so all plug-ins updated to have a dependency to JQuery plug-in, and call it a bit different). I have JQuery API Plugin 3.7.1-2, which is a dependency of the plug-in. Could anyone confirm they have this issue even though they also have the JQuery API Plug-in, please? Just so we rule out that as the possible root cause. Thanks!   Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937) Maven home: /opt/apache-maven-3.9.9 Java version: 17.0.13, vendor: Ubuntu, runtime: /usr/lib/jvm/java-17-openjdk-amd64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "6.8.0-52-generic", arch: "amd64", family: "unix"    

          D. Saville added a comment -

          kinow 

          The screenshot you posted for the "freestyle job working" doesn't show that you used the filter field to change the value of paramA.  Using the filter is were it fails.  I have the required plugins installed for my test case.

          Freestyle job failed screenshot:

          D. Saville added a comment - kinow   The screenshot you posted for the "freestyle job working" doesn't show that you used the filter field to change the value of paramA.  Using the filter is were it fails.  I have the required plugins installed for my test case. Freestyle job failed screenshot:

          Federico Alaimo added a comment -

          Hi, any updates on this issue? it's been there for months now.

          I understand you're doing this as best effort. I'd like to know if you are still planning to have this fixed, and if yes, some time estimation.

          For info, the last working version, `2.8.3` is still compatible, with Jenkins 2.492.1. But at some point it might become a problem.

          Thanks! 

          Federico Alaimo added a comment - Hi, any updates on this issue? it's been there for months now. I understand you're doing this as best effort. I'd like to know if you are still planning to have this fixed, and if yes, some time estimation. For info, the last working version, `2.8.3` is still compatible, with Jenkins 2.492.1. But at some point it might become a problem. Thanks! 

          Bruno P. Kinoshita added a comment -

          Hi falaimo ,

          Definitely planning to fix this. There is obviously no estimation. If I were employed to work on this I could answer this, but this is on volunteer time. If fixing this is urgent to you, you can reach out to CloudBees or other IT companies (there was one in Denmark that maintained some plugins) and pay for the support. I got some pull requests from people employed by others to fix issues like this.

          Or if you know some Java, you can send a PR and I'll be glad to review it. The regression we had was due to changes introduced due to changes in Jenkins. I received some PRs from people involved with those changes, with all tests passing, but some corner cases which were not still tested slipped the review, and ended up breaking the latest versions.

          I'm trying to fix it as best as I can on my volunteer time, but since Jenkins is changing (for security reasons, new Java versions, deleting deprecated code, etc.), it's a bit of a moving target. I prepared a PR for another regression and asked users to test it if anyone had time, but even users impacted by that change didn't seem to have time to volunteer to test it.

          So answering your questions:

          >I understand you're doing this as best effort

          Thank you,

          >I'd like to know if you are still planning to have this fixed, and if yes, some time estimation.

          Yes, and as soon as I can, but I do cannot sacrifice life or $work time on this, especially since my current employer is also not using the plug-in, which makes it even more difficult.

          >For info, the last working version, `2.8.3` is still compatible, with Jenkins 2.492.1. But at some point it might become a problem.

          There are companies that provide paid support, people who work on paid bounty for Open Source. I'm very happy to review if I receive a PR from other companies or Open Source projects, etc.., and try to review them over weekends and get them merged. I haven't merged the ones sent recently about other deprecated code (from one of Jenkins maintainers) and some style changes (CSS) as I hope to be able to cut a release with possible fix for the existing regressions (the less changes we have now, the easier it should be to isolate).

          If you can help, please try to test things, confirm what's working or not, or send code & tests

          Cheers

          Bruno P. Kinoshita added a comment - Hi falaimo , Definitely planning to fix this. There is obviously no estimation. If I were employed to work on this I could answer this, but this is on volunteer time. If fixing this is urgent to you, you can reach out to CloudBees or other IT companies (there was one in Denmark that maintained some plugins) and pay for the support. I got some pull requests from people employed by others to fix issues like this. Or if you know some Java, you can send a PR and I'll be glad to review it. The regression we had was due to changes introduced due to changes in Jenkins. I received some PRs from people involved with those changes, with all tests passing, but some corner cases which were not still tested slipped the review, and ended up breaking the latest versions. I'm trying to fix it as best as I can on my volunteer time, but since Jenkins is changing (for security reasons, new Java versions, deleting deprecated code, etc.), it's a bit of a moving target. I prepared a PR for another regression and asked users to test it if anyone had time, but even users impacted by that change didn't seem to have time to volunteer to test it. So answering your questions: >I understand you're doing this as best effort Thank you, >I'd like to know if you are still planning to have this fixed, and if yes, some time estimation. Yes, and as soon as I can, but I do cannot sacrifice life or $work time on this, especially since my current employer is also not using the plug-in, which makes it even more difficult. >For info, the last working version, `2.8.3` is still compatible, with Jenkins 2.492.1. But at some point it might become a problem. There are companies that provide paid support, people who work on paid bounty for Open Source. I'm very happy to review if I receive a PR from other companies or Open Source projects, etc.., and try to review them over weekends and get them merged. I haven't merged the ones sent recently about other deprecated code (from one of Jenkins maintainers) and some style changes (CSS) as I hope to be able to cut a release with possible fix for the existing regressions (the less changes we have now, the easier it should be to isolate). If you can help, please try to test things, confirm what's working or not, or send code & tests Cheers

          Felipe added a comment - - edited

          kinow 

          I am glad to test a fix for this.

          Also, to reliably reproduce this bug:

          1. In the first Active Choice parameter, enter (or paste) a filter that exactly matches your desired result. This should cause the dropdown to display only one item.
          1. When only one item is shown, the second cascade parameter does not update as expected.
          1. Now, modify the filter by deleting a few characters so that multiple options are displayed. Then select the desired option from the list.
          1. In this case, the second parameter updates correctly.

           

          In summary, the issue occurs only when the filter returns exactly one option, at least in my case. I hope this clarifies the replication steps. Please let me know if any further details are needed.

          Felipe added a comment - - edited kinow   I am glad to test a fix for this. Also, to reliably reproduce this bug: In the first Active Choice parameter, enter (or paste) a filter that exactly matches your desired result. This should cause the dropdown to display only one item. When only one item is shown, the second cascade parameter does not update as expected. Now, modify the filter by deleting a few characters so that multiple options are displayed. Then select the desired option from the list. In this case, the second parameter updates correctly.   In summary, the issue occurs only when the filter returns exactly one option, at least in my case. I hope this clarifies the replication steps. Please let me know if any further details are needed.

            kinow Bruno P. Kinoshita
            chamacs D. Saville
            Votes:
            8 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated: