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

          D. Saville created issue -

          D. Saville added a comment -

          Of Note:  While my test case is a pipeline, the issue also happens in freestyle jobs.

          D. Saville added a comment - Of Note:  While my test case is a pipeline, the issue also happens in freestyle jobs.

          Maged Ahmed added a comment -

          Same issue with Jenkins 2.479.2 & Active Choices Plugin 2.8.6

          Maged Ahmed added a comment - Same issue with Jenkins 2.479.2 & Active Choices Plugin 2.8.6

          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 made changes -
          Priority Original: Major [ 3 ] New: Critical [ 2 ]

          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"    

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

              Created:
              Updated: