Assets automation rule involving HTTP request to Jira stops working due to 403 response code

Still need help?

The Atlassian Community is here for you.

Ask the community

   

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

Summary

An administrator notices that an Assets automation rule, triggering an HTTP request, suddenly stops working. Automation rule status column shows (tick) on the automation rule list for that object scheme.

Environment

JSM 9.x (bundled Assets plugin)

Diagnosis

  • Go to Logging and profiling page and enable DEBUG logging for com.riadalabs.jira.plugins.insight.services.automation.log.AutomationLogger package
  • Run the automation rule 
  • insight_automation.log file indicates the automation rule has been executed and an HTTP request has been triggered, in this case, to the Jira application itself, to edit a issue custom field and assign an Assets object:

    2024-04-05 07:28:59,460 [insight-event-2] | Execute Rule action (AutomationAttributeValueAction): Done, id:10, event [id: 16, aql: No aql, condition: 	objecttype = Server
    2024-04-05 07:28:59,474 [insight-event-2] | Got rule and event for insightObjectAsyncEvent: null, id: 19 - InsightObjectEvent eventType: OBJECT_CREATED, rule id: 13, name: TEST - custom field 36109, isActive true, objectRuleEvent id: 19 and object: Server test (SERV-1234)
    2024-04-05 07:28:59,477 [insight-event-2] | doAction(), called for event class: InsightObjectCreatedEvent
    2024-04-05 07:28:59,477 [insight-event-2] | Object name: Server test, id: 871904
    2024-04-05 07:28:59,477 [insight-event-2] | Execute Rule action (AutomationRuleHttpRequestAction): Start, id: 13, event [id: 19, aql: No aql], condition: objecttype = Server
    2024-04-05 07:28:59,758 [insight-event-2] | AutomationRuleHttpRequestAction action data after replacing placeholders: {"url":"https://localhost/jira/rest/api/2/issue/ITSM-83346","method":"PUT","postData":"{\n\t\"update\" : \n\t{\n\t\t\"customfield_36109\": [{\"set\" : \"SERV-1234\"}],\n\t\t\"customfield_38200\" : [{\"set\" : [{\"key\":\"SERV-1234\"}]}]\n\t} \n}","username":"admin","password":"********"}
    2024-04-05 07:28:59,858 [insight-event-2] | Execute Rule action (AutomationRuleHttpRequestAction), Result: PUT executed. Url: https://localhost/jira/rest/api/2/issue/ITSM-83346 data: {
    	"update" : 
    	{
    		"customfield_36109": [{"set" : "SERV-1234"}],
    		"customfield_38200" : [{"set" : [{"key":"SERV-1234"}]}]
    	} 
    }
  • atlassian_jira.log, shows an error with 403 response code:

    2024-04-05 07:28:59,759-0500 insight-event-2 INFO admin     [c.r.j.p.i.services.util.InsightHttpRequester] InsightHttpRequester.doRequest, url: https://localhost/jira/rest/api/2/issue/ITSM-83346, method: PUT
    2024-04-05 07:28:59,857-0500 insight-event-2 ERROR admin     [c.r.j.p.i.services.util.InsightHttpRequester] InsightHttpRequester.doRequest() Failed to send Http request for data: {"url":"https://localhost/jira/rest/api/2/issue/ITSM-83346","method":"PUT","postData":"{\n\t\"update\" : \n\t{\n\t\t\"customfield_36109\": [{\"set\" : \"SERV-1234\"}],\n\t\t\"customfield_38200\" : [{\"set\" : [{\"key\":\"SERV-1234\"}]}]\n\t} \n}","username":"admin","password":"********"}
    java.io.IOException: Server returned HTTP response code: 403 for URL: https://localhost/jira/rest/api/2/issue/ITSM-83346
    	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1924)
    	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520)
    	at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:250)
    	at com.riadalabs.jira.plugins.insight.services.util.InsightHttpRequester.doRequest(InsightHttpRequester.java:80)
    	at com.riadalabs.jira.plugins.insight.services.automation.action.AutomationRuleHttpRequestAction.doActionSafe(AutomationRuleHttpRequestAction.java:56)
    	at com.riadalabs.jira.plugins.insight.services.automation.action.AbstractInsightAutomationAction.doAction(AbstractInsightAutomationAction.java:107)
    	at com.riadalabs.jira.plugins.insight.services.automation.rule.impl.AutomationRuleEngineImpl.executeAction(AutomationRuleEngineImpl.java:685)
    	at com.riadalabs.jira.plugins.insight.services.automation.rule.impl.AutomationRuleEngineImpl.executeActions(AutomationRuleEngineImpl.java:670)
    	at com.riadalabs.jira.plugins.insight.services.automation.rule.impl.AutomationRuleEngineImpl.matchConditionAndExecuteActions(AutomationRuleEngineImpl.java:463)
    	at com.riadalabs.jira.plugins.insight.services.automation.rule.impl.AutomationRuleEngineImpl.executeAsConfiguredUser(AutomationRuleEngineImpl.java:261)
    	at com.riadalabs.jira.plugins.insight.services.automation.rule.impl.AutomationRuleEngineImpl.handleAsyncEvent(AutomationRuleEngineImpl.java:214)
    	at com.riadalabs.jira.plugins.insight.services.automation.event.AutomationRuleEventListener.onAsyncEvent(AutomationRuleEventListener.java:94)

Cause

The cause for this issue is unauthorized request by the running automation user. It can be due to load balancer configuration, insufficient permissions on Jira object that is about to be altered, captcha issue or similar.

Solution

  1. Run a CURL request against the same endpoint, using the same payload and with the same user. The curl response should give more information about the problem. Example request, deducted from the Diagnosis step:

    curl -v -u admin:<password> -d "@data.json" -X POST https://localhost/jira/rest/api/2/issue/ITSM-83346

    data.json:

    {
    "update" : 
    	{
    		"customfield_36109": [{"set" : "SERV-1234"}],
    		"customfield_38200" : [{"set" : [{"key":"SERV-1234"}]}]
    	} 
    }
  2.  Fix the problem, as per the curl response.

In case you are not able to find out the problem, please raise a case with Atlassian Support.

Last modified on Apr 23, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.