I have a python script that uses the Atlassian REST API to create issues on JIRA, the script itself works fine, the problem I'm having is a specific post function on my issuetype that kills the workflow and makes JIRA not send the issue key back to my script.
The function is the create issue function by JWT (JIRA Workflow Toolbox), and a specific field, "New Labels". I found out that this is the issue by adding fields one by one to the post function until I could no longer create the issue anymore.
This is the error I get as an HTTP response:
The error from the log is:
2025-01-14 11:06:55,467-0600 https-jsse-nio-8443-exec-2 url: /rest/api/2/issue; user: pibrahim ERROR pibrahim 666x12954211x1 1hzzle7
192.168.20.115,10.40.13.63 /rest/api/2/issue [c.a.j.bc.issue.DefaultIssueService] Error creating issue: com.atlassian.jira.exception.CreateException: index -1, length 1
Caused by: com.atlassian.jira.workflow.WorkflowException: index -1, length 1
at com.atlassian.jira.workflow.OSWorkflowManager.createIssue(OSWorkflowManager.java:780)
at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:577)
... 311 more
Caused by: java.lang.StringIndexOutOfBoundsException: index -1, length 1
at java.base/java.lang.String.checkIndex(Unknown Source)
at java.base/java.lang.AbstractStringBuilder.charAt(Unknown Source)
at java.base/java.lang.StringBuffer.charAt(Unknown Source)
at com.decadis.jira.xapps.library.internal.model.GeneralizedFieldImpl.getStringValue(GeneralizedFieldImpl.java:6381)
at com.decadis.jira.xapps.library.internal.model.GeneralizedFieldImpl.getStringValue(GeneralizedFieldImpl.java:6150)
at com.decadis.jira.xapps.library.internal.model.GeneralizedFieldImpl.getStringValue(GeneralizedFieldImpl.java:6116)
at com.fca.jira.plugins.workflowToolbox.CreateIssue.setFields(CreateIssue.java:823)
at com.fca.jira.plugins.workflowToolbox.CreateIssue.execute(CreateIssue.java:248)
And below is the on create post function:
My testing was to take out all fields in the above post function, run my script and see if the subtask gets created under the main issue or not, if it did, I'd add a new field and test again.
The subtask stopped getting created once I added the "New Labels" field.
I also tried having all the fields in the screenshot above present EXCEPT for the "New Labels" field, and again the subtask was created fine.
Also worth noting that creating the JIRA issue through the UI does not cause this problem, only when it's created via a REST API call.
Trying through POSTMAN with the following Body:
{
"fields": {
"project": {"id": "16903"},
"summary": "Sample Summary",
"issuetype": {"name": "Implementation Development"},
"reporter": {"name": "cp_admin"},
"priority": {"name": "Medium"},
"description": "Sample Description",
"customfield_12569": "",
"customfield_10635": "",
"timetracking": {"originalEstimate": "0.5h", "remainingEstimate": "0.5h"},
"labels": [""],
"customfield_15005": {"value": "Auto bottom up"},
"customfield_15300": ["skill#_-_B2"],
"customfield_11413": "randomIssueKey",
"customfield_11329": "2025-04-22",
"customfield_11330": "2025-04-22",
"customfield_12020": {"value": "Other"},
"customfield_12502": {"value": "New Implementation"},
"customfield_11503": {"name": "pibrahim"},
"customfield_11421": {"name": "pibrahim"},
"customfield_10637": "test"
}
}
And I get more or less the same error message:
That goes away though and creates the issue if I don't include "labels": [""] in my API call.
Is this a known issue with JWT? I can have my script not send the labels field at all if it's blank, but I'd want to know if this is a misunderstanding on my part on how the post function works with blank fields, or if this is a bug that should be addressed by JWT.
Try "labels":[] without the "" inside. When you include the empty string, JWT is looking for a label that matches this empty string, which doesn't exist.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.