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

Optional block in jelly has inconsistent behaviour when translated to JSON

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • core
    • None

      // code placeholder
      

      When using an optional block in jelly configuration files, if the checkbox is not checked in the UI, when sent in the Stapler request, sometimes translates to an empty JSON object some other times in a String.

      Example: given the following optional block

      <f:optionalBlock name="enable" title="${%Enable}" checked="${instance != null and instance.count != null}">

      belonging to the java com.example.Property.java class, if it's not checked in the UI, the stapler request can either receive a JSON containing

       

      "com.example.Property":{}}" 
      

      or

      com-example-Property":{"enable":false}

       

       

      When you submit the form, you will get an error like

      JSONObject["someField"] is not a JSONObject

       

          [JENKINS-43326] Optional block in jelly has inconsistent behaviour when translated to JSON

          valentina armenise created issue -
          Ryan Campbell made changes -
          Issue Type Original: Improvement [ 4 ] New: Bug [ 1 ]
          valentina armenise made changes -
          Description Original: Optional block in jelly configuration files, if it's not checked sometimes translates to an empty JSON object some other times in a String.

          Example: given the following optional block
          {noformat}
          <f:optionalBlock name="enable" title="${%Enable}" checked="${instance != null and instance.count != null}">{noformat}
          belonging to the java com.example.Property.java class, if it's not checked in the UI, the stapler request can either receive a JSON containing

           
          {noformat}
          "com.example.Property":{}}" 
          {noformat}
          or
          {noformat}
          com-example-Property":{"enable":false}{noformat}
          I believe the behaviour should be consistent.

           
          New: When using an optional block in jelly configuration files, if the checkbox is not checked in the UI, when sent in the Stepler request, sometimes translates to an empty JSON object some other times in a String.

          Example: given the following optional block
          {noformat}
          <f:optionalBlock name="enable" title="${%Enable}" checked="${instance != null and instance.count != null}">{noformat}
          belonging to the java com.example.Property.java class, if it's not checked in the UI, the stapler request can either receive a JSON containing

           
          {noformat}
          "com.example.Property":{}}" 
          {noformat}
          or
          {noformat}
          com-example-Property":{"enable":false}{noformat}
          I believe the behaviour should be consistent.

           
          valentina armenise made changes -
          Description Original: When using an optional block in jelly configuration files, if the checkbox is not checked in the UI, when sent in the Stepler request, sometimes translates to an empty JSON object some other times in a String.

          Example: given the following optional block
          {noformat}
          <f:optionalBlock name="enable" title="${%Enable}" checked="${instance != null and instance.count != null}">{noformat}
          belonging to the java com.example.Property.java class, if it's not checked in the UI, the stapler request can either receive a JSON containing

           
          {noformat}
          "com.example.Property":{}}" 
          {noformat}
          or
          {noformat}
          com-example-Property":{"enable":false}{noformat}
          I believe the behaviour should be consistent.

           
          New: When using an optional block in jelly configuration files, if the checkbox is not checked in the UI, when sent in the Stapler request, sometimes translates to an empty JSON object some other times in a String.

          Example: given the following optional block
          {noformat}
          <f:optionalBlock name="enable" title="${%Enable}" checked="${instance != null and instance.count != null}">{noformat}
          belonging to the java com.example.Property.java class, if it's not checked in the UI, the stapler request can either receive a JSON containing

           
          {noformat}
          "com.example.Property":{}}" 
          {noformat}
          or
          {noformat}
          com-example-Property":{"enable":false}{noformat}
          I believe the behaviour should be consistent.

           
          Ryan Campbell made changes -
          Link New: This issue is duplicated by JENKINS-43184 [ JENKINS-43184 ]
          Ryan Campbell made changes -
          Remote Link New: This issue links to "jenkins#2858 PR (Web Link)" [ 16303 ]
          Ryan Campbell made changes -
          Description Original: When using an optional block in jelly configuration files, if the checkbox is not checked in the UI, when sent in the Stapler request, sometimes translates to an empty JSON object some other times in a String.

          Example: given the following optional block
          {noformat}
          <f:optionalBlock name="enable" title="${%Enable}" checked="${instance != null and instance.count != null}">{noformat}
          belonging to the java com.example.Property.java class, if it's not checked in the UI, the stapler request can either receive a JSON containing

           
          {noformat}
          "com.example.Property":{}}" 
          {noformat}
          or
          {noformat}
          com-example-Property":{"enable":false}{noformat}
          I believe the behaviour should be consistent.

           
          New: When using an optional block in jelly configuration files, if the checkbox is not checked in the UI, when sent in the Stapler request, sometimes translates to an empty JSON object some other times in a String.

          Example: given the following optional block
          {noformat}
          <f:optionalBlock name="enable" title="${%Enable}" checked="${instance != null and instance.count != null}">{noformat}
          belonging to the java com.example.Property.java class, if it's not checked in the UI, the stapler request can either receive a JSON containing

           
          {noformat}
          "com.example.Property":{}}" 
          {noformat}
          or
          {noformat}
          com-example-Property":{"enable":false}{noformat}
          I believe the behaviour should be consistent.

           

           

           
          Ryan Campbell made changes -
          Description Original: When using an optional block in jelly configuration files, if the checkbox is not checked in the UI, when sent in the Stapler request, sometimes translates to an empty JSON object some other times in a String.

          Example: given the following optional block
          {noformat}
          <f:optionalBlock name="enable" title="${%Enable}" checked="${instance != null and instance.count != null}">{noformat}
          belonging to the java com.example.Property.java class, if it's not checked in the UI, the stapler request can either receive a JSON containing

           
          {noformat}
          "com.example.Property":{}}" 
          {noformat}
          or
          {noformat}
          com-example-Property":{"enable":false}{noformat}
          I believe the behaviour should be consistent.

           

           

           
          New: {code:java}
          // code placeholder
          {code}
          When using an optional block in jelly configuration files, if the checkbox is not checked in the UI, when sent in the Stapler request, sometimes translates to an empty JSON object some other times in a String.

          Example: given the following optional block
          {noformat}
          <f:optionalBlock name="enable" title="${%Enable}" checked="${instance != null and instance.count != null}">{noformat}
          belonging to the java com.example.Property.java class, if it's not checked in the UI, the stapler request can either receive a JSON containing

           
          {noformat}
          "com.example.Property":{}}" 
          {noformat}
          or
          {noformat}
          com-example-Property":{"enable":false}{noformat}
           

           

          When you submit the form, you will get an error like {noformat}JSONObject["someField"] is not a JSONObject{noformat}

           
          Jesse Glick made changes -
          Link New: This issue is duplicated by JENKINS-43559 [ JENKINS-43559 ]
          James Dumay made changes -
          Remote Link New: This issue links to "CloudBees Internal OSS-2150 (Web Link)" [ 18402 ]

            Unassigned Unassigned
            varmenise valentina armenise
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: