Error message from Workflow Validator not displaying on Jira Cloud Issue Create Screen

When adding a workflow validator through Forge, the value of the errorMessage property isn’t being displayed correctly in the Create Issues window. Instead of showing the configured message, it shows the default Jira Cloud error message.

Example manifest that can be used to reproduce the error:

modules:
  jira:workflowValidator:
    - key: key-example
      name: name-example
      description: An example description.
      expression: issue.parent == null
      errorMessage: "This error message is not being displayed."

What I see:

I’m not sure if I’m configuring the Jira workflow validator correctly. I’m trying to follow the documentation and set up custom error messages for my users to see. Any suggestions for workarounds? Is this affecting anyone else?

1 Like

Hey @VinciusTrainotti! Thanks for reaching out to us with your question. I can see that this is your first time posting in our community, so welcome!

Thanks for your patience with us on getting back to you. I’ve managed to create a small sample app locally with the same expression and can confirm that this expression is not true after being evaluated and hence will not yield the error you have provided. As for the error that you are receiving, I would assume that there is another workflow configuration that is triggering and is producing the error that you are experiencing however this is a guess and I couldn’t say more without knowing more about your specific workflow configuration and validators.

issue.parent, when it does not exist is undefined rather than null as in the case that there is no parent issue, an Issue is never constructed and so null is never returned, as we would expect according to the Jira Expression docs.

Swapping null for undefined for issue.parent == undefined does not produce the correct error either and instead produces a different error saying that the provided expression does not actually resolve to a boolean value.

What we can do is check for object existence with typeof issue.parent == 'undefined' which produces the desired behaviour.

Alternatively, you should be able to use this expression and leverage either the falsy or truthy nature of the parent object to achieve the desired functionality: issue.parent || false as per Jira Expression Boolean Operators.

Hope this helps! If you have any further questions please feel free to follow up!

Thanks for clarifying issue.parent would be undefined for issues that don’t have a parent issue. We haven’t really been able to use it the way you suggested to inhibit the creation of sub-tasks. Here are the attempts we made:

jira:workflowValidator:
  - key: example-no-sub-tasks
    name: No Sub-tasks
    description: Sub-tasks should never be created.
    expression: issue.parent || true
    errorMessage: "Please display this..."
  - key: example-no-sub-tasks-two
    name: No Sub-tasks 2
    description: Sub-tasks should never be created 2, electric boogaloo.
    expression: (typeof issue.parent) == 'undefined'
    errorMessage: "Please, let this be displayed"

Neither of these worked the way we expected them to, and none of them displayed the error message configured in the manifest. However, comparing issue.parent to null did allow us to make a validator that allowed only non-child issues to be created.

Regardless, we weren’t able to display the errorMessage and continue to get the same default error message shown in the picture @VinciusTrainotti attached to the first message in this thread.

This validator should circumvent any possibilities of the Jira expression not resolving to a Boolean type value, and can be used to show the errorMessage isn’t being displayed, however:

jira:workflowValidator:
  - key: example-no-non-bugs
    name: Only Bugs
    description: Only bugs can be created
    expression: issue.issueType.name == "Bug"
    errorMessage: "You can create only bugs!"

With this validator in the Create transition, issues of type Bug can be created without errors, but issues of any other types still show the same error message:

screenshot

Hi @WilsonMoncayo Thank you for following up with us!

You are correct, I was able to reproduce the errors you are seeing with the examples you have provided, thank you for that. These seem to be issues specific to issue creation. We have followed up with internally with both the issue creation and workflow teams respectively with this apparently recurring issue.

We believe that we have identified the cause of the error and are working on a fix. I will update this thread when there is more to share and when we can get this resolved for you.

Thanks for your patience!

1 Like

Hi @WilsonMoncayo @VinciusTrainotti !

Keeping everyone updated, a PR has been raised that should resolve the issue. It is currently pending approval. I will let everyone know once this change is merged and ready for use!

Thank you again for your patience!

1 Like