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

javax.mail.internet.AddressException: Local address contains control or whitespace on mercurial commits

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • mercurial-plugin
    • None
    • jenkins on linux

      It seems that jenkins is not able to use the email addresses from mercurial commits.

      Mercurial uses the Author field which has this format: "name surname <email@domain.com>".

      At same stage the < > are replaced by underlines.

      ERROR: Local address contains control or whitespace
      javax.mail.internet.AddressException: Local address contains control or whitespace in string ``John Doe _johm.doe@acme.com_''
      	at javax.mail.internet.InternetAddress.checkAddress(InternetAddress.java:1213)
      	at javax.mail.internet.InternetAddress.parse(InternetAddress.java:1091)
      	at javax.mail.internet.InternetAddress.parse(InternetAddress.java:633)
      	at javax.mail.internet.InternetAddress.<init>(InternetAddress.java:111)
      	at hudson.tasks.Mailer.StringToAddress(Mailer.java:152)
      	at hudson.tasks.MailSender.buildCulpritList(MailSender.java:411)
      	at hudson.tasks.MailSender.createEmptyMail(MailSender.java:367)
      	at hudson.tasks.MailSender.createFailureMail(MailSender.java:226)
      	at hudson.tasks.MailSender.getMail(MailSender.java:153)
      	at hudson.tasks.MailSender.execute(MailSender.java:99)
      	at hudson.tasks.Mailer.perform(Mailer.java:115)
      	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:717)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:692)
      	at hudson.model.Build$BuildExecution.post2(Build.java:183)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:639)
      	at hudson.model.Run.execute(Run.java:1513)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
      	at hudson.model.ResourceController.execute(ResourceController.java:88)
      	at hudson.model.Executor.run(Executor.java:236)
      

          [JENKINS-15253] javax.mail.internet.AddressException: Local address contains control or whitespace on mercurial commits

          I have the same issue in 1.484. It would be great to see this fixed as it causes a bumpy workflow as people don't get notified when causing a failed build For now the person checking in will just have to remember to watch the dashboard.

          If the need to set "System.setProperty("mail.mime.address.strict", "false");" to false is needed perhaps it can be a param read from a config file somewhere so people can easily turn on / off?

          Peter Reynolds added a comment - I have the same issue in 1.484. It would be great to see this fixed as it causes a bumpy workflow as people don't get notified when causing a failed build For now the person checking in will just have to remember to watch the dashboard. If the need to set "System.setProperty("mail.mime.address.strict", "false");" to false is needed perhaps it can be a param read from a config file somewhere so people can easily turn on / off?

          Jesse Glick added a comment -

          Replacing < and the like with _ is done to create the User.id. The question is how MailAddressResolver takes the User and determines an email address. Normally extractAddressFromId would handle this. Try going to /script and evaluating

          u = User.get('John Doe _johm.doe@acme.com_')
          println(u.fullName)
          println(hudson.tasks.MailAddressResolver.resolve(u))
          

          Jesse Glick added a comment - Replacing < and the like with _ is done to create the User.id . The question is how MailAddressResolver takes the User and determines an email address. Normally extractAddressFromId would handle this. Try going to /script and evaluating u = User.get( 'John Doe _johm.doe@acme.com_' ) println(u.fullName) println(hudson.tasks.MailAddressResolver.resolve(u))

          cowwoc added a comment - - edited

          Jesse,

          I ran the script you provided and got the same output for u.fullName and hudson.tasks.MailAddressResolver.resolve(u) (underscores both times). Bug JENKINS-16332 seems to indicate the problem lies in the Mercurial plugin. Are you saying that actually the bug lies in MailAddressResolver? If so, can you please reassign this to the appropriate component/person?

          On a side-note, please note that a lot of people are waiting on this bug (see the number of watchers on JENKINS-16332).

          cowwoc added a comment - - edited Jesse, I ran the script you provided and got the same output for u.fullName and hudson.tasks.MailAddressResolver.resolve(u) (underscores both times). Bug JENKINS-16332 seems to indicate the problem lies in the Mercurial plugin. Are you saying that actually the bug lies in MailAddressResolver? If so, can you please reassign this to the appropriate component/person? On a side-note, please note that a lot of people are waiting on this bug (see the number of watchers on JENKINS-16332 ).

          Jesse Glick added a comment -

          @cowwoc: if I knew where the bug lay, I would fix it. But I have tried several times to reproduce this without success, and have looked over all the associated code without any real clues. If you can reproduce it and you want it fixed then you need to debug it yourself. The id should have underscores (Display Name _email@host.com_), while the fullName should be as written in the changelog (Display Name <email@host.com>), and MailAddressResolver should produce the actual email (email@host.com).

          Jesse Glick added a comment - @cowwoc: if I knew where the bug lay, I would fix it. But I have tried several times to reproduce this without success, and have looked over all the associated code without any real clues. If you can reproduce it and you want it fixed then you need to debug it yourself. The id should have underscores ( Display Name _email@host.com_ ), while the fullName should be as written in the changelog ( Display Name <email@host.com> ), and MailAddressResolver should produce the actual email ( email@host.com ).

            jglick Jesse Glick
            ssbarnea Sorin Sbarnea
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: