Automation for Jira rule fails "java.lang.StringIndexOutOfBoundsException: begin 12, end 3, length 3" error

プラットフォームについて: Data Center - この記事は、Data Center プラットフォームのアトラシアン製品に適用されます。

このナレッジベース記事は製品の Data Center バージョン用に作成されています。Data Center 固有ではない機能の Data Center ナレッジベースは、製品のサーバー バージョンでも動作する可能性はありますが、テストは行われていません。サーバー*製品のサポートは 2024 年 2 月 15 日に終了しました。サーバー製品を利用している場合は、アトラシアンのサーバー製品のサポート終了のお知らせページにて移行オプションをご確認ください。

*Fisheye および Crucible は除く

要約

Automation for Jira rule fails "java.lang.StringIndexOutOfBoundsException: begin 12, end 3, length 3" error message.

環境

Automation for Jira all versions

診断

  • The Automation for Jira rule is triggered, but not successful.
  • The "Audit Log" of the Automation for Jira just say "FAILURE". It does not notify which section of the rule failed. 
  • In the logs (atlassian-jira.log), we see the below error. The error is caused by StringIndexOutOfBoundsException: begin 12, end 3, length 3. 

    2024-07-14 10:59:19,675+0200 automation-rule-executor:thread-3 ERROR Monitor     [c.c.a.api.service.SingleRuleExecutorServiceImpl] Unexpected error executing rule with context TenantContext{environment=prod, clientKey='com.codebarrel.tenant.global', tenantId=TenantId{id='00000000-0000-0000-0000-000000bbbbbb'}}: AutomationEvent{traceId=xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, clientKey='com.codebarrel.tenant.global', triggerType=EVENT, type='jira:issue_created:issue_created', projectIds=[10100], timestamp=Sun Jul 14 10:59:13 CEST 2024, authorAccountId='xxxxxx', auditItemBatchId=null, payload='{"timestamp":1720947553602,"webhookEvent":"jira:issue_created","properties":[],"comment":null,"issue":{"self":"https://BASE_URL/rest/api/2/issue/xxxx","id":xxxx,"key":"TEST-11","changelog":{"startAt":0,"maxResults":0,"total":0,"histories":null},"fields":{"customfield_11111":null,"resolution":null,"customfield_xxxxx":[{"self":"https://BASE_URL/rest/api/2/customFieldOption/xxxx","value":"No","id":"xxxx","disabled":false}],"customfield_xxxx":"{}","lastViewed":null,"customfield_xxxxx":{"id":"21","name":"xxxx","_links":{"self":"https://BASE_URL/rest/servicedeskapi/request/xxxx/sla/21"},"completedCycles":[]},"customfield_xxxxx":"Active Directory service problem","labels":[],"customfield_xxxxx":null,"customfield_xxxxx":null,"customfield_xxxxx":["xxxxxx"],"aggregatetimeoriginalestimate":null,"customfield_xxxxx":null,"customfield_xxxxx":null,"issuelinks":[],"assignee":null,"components":[],"customfield_xxxxx":null,"customfield_xxxxx...', ignoreOwnEvents=true, authorAutomationAddon=false, priority=5}
    java.lang.StringIndexOutOfBoundsException: begin 12, end 3, length 3
    	at java.base/java.lang.String.checkBoundsBeginEnd(Unknown Source)
    	at java.base/java.lang.String.substring(Unknown Source)
    	at java.base/java.lang.String.substring(Unknown Source)
    	at com.codebarrel.automation.api.service.SingleRuleExecutorServiceImpl.transformErrorMapToString(SingleRuleExecutorServiceImpl.java:497)
    	at com.codebarrel.automation.api.service.SingleRuleExecutorServiceImpl.lambda$handleErrors$7(SingleRuleExecutorServiceImpl.java:490)
    	at java.base/java.util.HashMap$EntrySet.forEach(Unknown Source)
    	at com.codebarrel.automation.api.service.SingleRuleExecutorServiceImpl.lambda$handleErrors$8(SingleRuleExecutorServiceImpl.java:490)
    	at java.base/java.util.HashMap$Values.forEach(Unknown Source)
    	at java.base/java.util.Collections$UnmodifiableCollection.forEach(Unknown Source)
    	at com.codebarrel.automation.api.service.SingleRuleExecutorServiceImpl.handleErrors(SingleRuleExecutorServiceImpl.java:488)
    	at com.codebarrel.automation.api.service.SingleRuleExecutorServiceImpl.auditLogInvalidRule(SingleRuleExecutorServiceImpl.java:482)
  • If we look into the stacktrace, we see the rule is trying to send a "issue created" webhook event (webhookEvent":"jira:issue_created). The event is further making 3 REST API calls -
    • https://BASE_URL/rest/api/2/issue/xxxxx
    • https://BASE_URL/rest/servicedeskapi/request/xxxx/sla/21
    • https://BASE_URL/rest/api/2/customFieldOption/xxxx
  • We can also see references to com.codebarrel.automation.api.service.SingleRuleExecutorServiceImpl package in the logs. This could mean some API calls are being made, resulting in an error.
  • The preceding logs before StringIndexOutOfBoundsException error also show that some events related to 'ScriptRunner for Jira' plugin/module of the automation rule were getting executed.

    2024-07-14 10:59:17,919+0200 automation-rule-executor:thread-3 WARN Monitor     [c.o.scriptrunner.runner.ScriptBindingsManager] Listener: Total billable hours [h] custom field automatic update
    2024-07-14 10:59:17,919+0200 automation-rule-executor:thread-3 WARN Monitor     [c.o.scriptrunner.runner.ScriptBindingsManager] Initial event class: class com.atlassian.jira.event.issue.IssueEvent
    2024-07-14 10:59:17,920+0200 automation-rule-executor:thread-3 WARN Monitor     [c.o.scriptrunner.runner.ScriptBindingsManager] event class: class com.atlassian.jira.event.issue.IssueEvent
    2024-07-14 10:59:17,920+0200 automation-rule-executor:thread-3 WARN Monitor     [c.o.scriptrunner.runner.ScriptBindingsManager] event properties: [time:XXXXX, params:[eventsource:action, baseurl:https://BASE_URL], SEND_MAIL:sendMail, BASE_URL_PARAM_NAME:baseurl, CUSTOM_FIELDS_PARAM_NAME:com.atlassian.jira.event.issue.CUSTOM_FIELDS, WATCHERS_PARAM_NAME:com.atlassian.jira.event.issue.WATCHERS, CHANGE_HISTORY_PARAM_NAME:com.atlassian.jira.event.issue.CHANGE_HISTORY, COMMENTS_PARAM_NAME:com.atlassian.jira.event.issue.COMMENTS, issue:TEST-11, user:Monitor(monitor), worklog:null, changeGroup:[issue:xxxxx, author:monitor, created:2024-07-14 10:59:17.773, id:xxxxx], comment:null, eventTypeId:2, subtasksUpdated:true, sendMail:true, redundant:false, spanningOperation:Optional.empty, changeLog:[issue:xxxx, author:monitor, created:2024-07-14 10:59:17.773, id:xxxx], class:class com.atlassian.jira.event.issue.IssueEvent, project:Project: TEST]
    2024-07-14 10:59:17,921+0200 automation-rule-executor:thread-3 WARN Monitor     [c.o.scriptrunner.runner.ScriptBindingsManager] issue key: TEST-11
    2024-07-14 10:59:17,925+0200 automation-rule-executor:thread-3 WARN Monitor     [c.o.scriptrunner.runner.ScriptBindingsManager] formaRozliczaniaValue is EMPTY
    2024-07-14 10:59:17,925+0200 automation-rule-executor:thread-3 WARN Monitor     [c.o.scriptrunner.runner.ScriptBindingsManager] issue: TEST-11 - Time logged [h]: 0.0

原因

When we check the automation rule, it's likely to have the Run a Script module in the rule. This is a module provided by ScriptRunner for Jira plugin. It's possible that a custom script configured in this module is making a REST API call that is resulting in the error.

ソリューション

  • For 'testing' purposes, take a backup of the "script" present in Run a script module of the rule, "delete" the Run a script module and save/publish the automation rule.
  • Trigger the automation rule again. We should not see StringIndexOutOfBoundsException error message.
  • This suggest the error is due to the custom script present in the "Run a script" module of the automation rule. The script present in the Run a script module is provided by ScriptRunner for Jira plugin. This is a third-party plugin provided by the vendor Adaptavist.
  • As the script is provided by third-party vendor, contact the vendor team to identify the error in the script and resolve the issue. 

    Providing support to issues related to third-party plugins fall outside the Support scope as per out Atlassian Support Offerings.


最終更新日: 2025 年 1 月 10 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.