Automation for Jira fails to copy components list to label with error message "The label contains spaces which is invalid"

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible


When running Automation for Jira rules to copy component values to the labels list, it fails with a "The label 'XXXXXX' contains spaces which is invalid (labels)" error message:

Error editing issues




The error message happens because:

  • The rule is configured to copy the name of the Component Name into the Label using the smart value below:

Copy component name into Label field using smart value
1 {{}}


To solve the Label requirement to not include space characters, while copying the Component values to the Labels list, it's possible to replace the space characters with another character (a hyphen, for example) using an "Additional Fields" custom script.

  1. To duplicate the Components List to the Labels list, changing the space characters to a hyphen using Automation for Jira, please check the steps below:

  2. Create your Automation Rule and configure the conditions to trigger the rule.

  3. Add an Edit issue action.

    1. Expand the drop-down list Choose fields to set... and select the Labels field.

    2. Add the script below to the Additional fields text field.

      1 2 3 4 5 { "fields": { "labels": {{" ","-")}} } }
    3. The Edit Issue action will look like this:

      edit issue action

4. Save the rule and enable it.

The suggested script can duplicate the components items to the label list

Please have in mind that the suggested script will duplicate the Components items to the Label list on the issue, removing any other Label from the issue that it's not on the Component's list.


Please find below an example of the results for the suggested script:


Updated on May 31, 2024

Still need help?

The Atlassian Community is here for you.