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

checkJobName api always return an extra blank line in response body: " <div/>"

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: In Progress (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Component/s: jobgenerator-plugin
    • Labels:
      None
    • Environment:
      Linux 2.6.32-220.23.2.ali927.el5.x86_64 x86_64
      Jenkins ver. 2.112
    • Similar Issues:

      Description

      on create job page, when typing in the job name text box, Jenkins call checkJobName api to check the item name, but this api always return an extra blank line in response body: "  <div/>"

      It caused the UI disable the submit button and I could never create a job. Please see the screenshot attached.

       

      An example of the checkJobName api call and response:
      Request URL:
      http://myjenkins.com/view/all/checkJobName?value=dfd
      Response:

      HTTP/1.1 200 OK Date: Thu, 22 Mar 2018 02:33:27 GMT Content-Type: text/html;charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive Vary: Accept-Encoding X-Content-Type-Options: nosniff Server: Tengine/Aserver Strict-Transport-Security: max-age=0 Timing-Allow-Origin: * EagleEye-TraceId: 0a67792f15216860072187973e2e7b RequestUri: jenkins.qa.umeng.com/view/all/checkJobName RequestApp: jenkins.qa.umeng.com Content-Encoding: gzip

       
      <div/>

        Attachments

          Activity

          Hide
          xpblack pan xu added a comment -

          compare to another Jenkins server on Mac, the Difference between response body is: the linux server return an extra empty line before the "<div/>", please see the screenshot attached. I update the bug description

          Show
          xpblack pan xu added a comment - compare to another Jenkins server on Mac, the Difference between response body is: the linux server return an extra empty line before the "<div/>", please see the screenshot attached. I update the bug description
          Hide
          cyberjoac Joachim Hagege added a comment -

          +1. Did you find any solution for this ? 

          Show
          cyberjoac Joachim Hagege added a comment - +1. Did you find any solution for this ? 
          Hide
          dplavcic Dalibor Plavcic added a comment - - edited

          Hi,

          from this screenshot I can't see if you selected any item (FreeStyle Project, Maven, Pipeline...) from the list?

          When we first land on '/view/all/newJob' page no item category is selected (this is the key).

          If we choose existing item name we won't be able to create new project which is ok, but if we choose non existing name we also won't be able to create new project because no item category is selected.

          Preposition:

          1) Add hover selector to OK button to provide user info to select item category.

           

           

          Show
          dplavcic Dalibor Plavcic added a comment - - edited Hi, from this screenshot I can't see if you selected any item (FreeStyle Project, Maven, Pipeline...) from the list? When we first land on '/view/all/newJob' page no item category is selected (this is the key). If we choose existing item name we won't be able to create new project which is ok, but if we choose non existing name we also won't be able to create new project because no item category is selected. Preposition: 1) Add hover selector to OK button to provide user info to select item category.    
          Hide
          xpblack pan xu added a comment - - edited

          Sorry for the late reply. " select an item" is not the key root cause for this issue.

          See the latest attached screenshot please. I select an item category first, then type in the name text box. the submit button is still disabled.

          The root cause is (in screenshot) the checkJobName api return an extra blank line in response.

          Show
          xpblack pan xu added a comment - - edited Sorry for the late reply. " select an item" is not the key root cause for this issue. See the latest attached screenshot please. I select an item category first, then type in the name text box. the submit button is still disabled. The root cause is (in screenshot) the  checkJobName  api return an extra blank line in response.
          Hide
          wayne wayne he added a comment -

          Same issue found for Jenkins. Everybody who fixed this issue ?

          Show
          wayne wayne he added a comment - Same issue found for Jenkins. Everybody who fixed this issue ?
          Hide
          tonnyaz A Z added a comment - - edited

          This is a bug, and I just find a way to modyfy add-item.js on index.html to fix it temporarily.

          The server sometimes will response with "\n</div>", and the page can't solve the situation and go to the error.

           

          [JenkinURL]/static/944f39f7/jsbundles/add-item.js
              // Init NameField
              $('input[name="name"]', '#createItem').on("blur input", function() {
                if (!isItemNameEmpty()) {
                  var itemName = $('input[name="name"]', '#createItem').val();
                  $.get("checkJobName", { value: itemName }).done(function(data) {
                    var message = parseResponseFromCheckJobName(data);
                    //[BUG] When the checkJobName API response with "\n</div>", the message will be not '' ,message.charCodeAt(0)=10, message.lenth=1, then it will go to activateValidationMessage and will come out the above discussion situation.
                    if (message !== '') {
                      activateValidationMessage('#itemname-invalid', '.add-item-name', message);
                    } else {
                      cleanValidationMessages('.add-item-name');
                      showInputHelp('.add-item-name');
                      setFieldValidationStatus('name', true);
                      if (getFormValidationStatus()) {
                        enableSubmit(true);
                      }
                    }
                  });
          

          The solve method:

          ''.charCodeAt(0)=NaN

          modyfy /static/944f39f7/jsbundles/add-item.js

           

           

          if (message !== '') {
          
          Change to --->
          
          if (message !== '' && Number.isNaN(message.charCodeAt(0))) {

          After that, it will work OK.

          Hope Jenkins could fix the problem quickly.

           

          Show
          tonnyaz A Z added a comment - - edited This is a bug, and I just find a way to modyfy add-item.js on index.html to fix it temporarily. The server sometimes will response with "\n</div>", and the page can't solve the situation and go to the error.   [JenkinURL]/ static /944f39f7/jsbundles/add-item.js // Init NameField $( 'input[name= "name" ]' , '#createItem' ).on( "blur input" , function() { if (!isItemNameEmpty()) { var itemName = $( 'input[name= "name" ]' , '#createItem' ).val(); $.get( "checkJobName" , { value: itemName }).done(function(data) { var message = parseResponseFromCheckJobName(data); //[BUG] When the checkJobName API response with "\n</div>" , the message will be not '' ,message.charCodeAt(0)=10, message.lenth=1, then it will go to activateValidationMessage and will come out the above discussion situation. if (message !== '') { activateValidationMessage( '#itemname-invalid' , '.add-item-name' , message); } else { cleanValidationMessages( '.add-item-name' ); showInputHelp( '.add-item-name' ); setFieldValidationStatus( 'name' , true ); if (getFormValidationStatus()) { enableSubmit( true ); } } }); The solve method: ''.charCodeAt(0)=NaN modyfy /static/944f39f7/jsbundles/add-item.js     if (message !== '') { Change to ---> if (message !== '' && Number .isNaN(message.charCodeAt(0))) { After that, it will work OK. Hope Jenkins could fix the problem quickly.  

            People

            Assignee:
            dplavcic Dalibor Plavcic
            Reporter:
            xpblack pan xu
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated: