It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage
Highlighted

REST - HTTP_40x -> JRJC tries to JSON-parse HTML error page Edited

When accessing the Jira REST API through JRJC with invalid credentials or insufficient privileges, then AbstractAsynchronousRestClient tries to parse the HTML error page returned by the Jira Server as JSON with Jettison.

This concludes in a "JSONException: A JSONObject text must begin with '{' at character 11 of [full HTML page content]".
As the exception message contains the full HTML error page data, it's quite huge:

Caused by: java.util.concurrent.ExecutionException: RestClientException{statusCode=Optional.of(403), errorCollections=[]}
at java.util.concurrent.CompletableFuture.reportGet(Unknown Source)
at java.util.concurrent.CompletableFuture.get(Unknown Source)
at io.atlassian.util.concurrent.Promises$OfStage.get(Promises.java:353)
at com.atlassian.jira.rest.client.internal.async.DelegatingPromise.get(DelegatingPromise.java:101)
at [STRIPPED].jira.JiraClient.fetchCustomFields(JiraClient.java:272)
... 9 more
Caused by: RestClientException{statusCode=Optional.of(403), errorCollections=[]}
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$2.apply(AbstractAsynchronousRestClient.java:178)
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$2.apply(AbstractAsynchronousRestClient.java:170)
at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:49)
at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:10)
at io.atlassian.util.concurrent.Promises$OfStage.lambda$fold$4(Promises.java:332)
at io.atlassian.util.concurrent.Promises.lambda$biFunction$7(Promises.java:422)
at java.util.concurrent.CompletableFuture.uniHandle(Unknown Source)
at java.util.concurrent.CompletableFuture$UniHandle.tryFire(Unknown Source)
at java.util.concurrent.CompletableFuture.postComplete(Unknown Source)
at java.util.concurrent.CompletableFuture.complete(Unknown Source)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$1.lambda$doCompleted$0(SettableFuturePromiseHttpPromiseAsyncClient.java:37)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient.runInContext(SettableFuturePromiseHttpPromiseAsyncClient.java:61)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalDelegateRunnable.run(SettableFuturePromiseHttpPromiseAsyncClient.java:129)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.codehaus.jettison.json.JSONException: A JSONObject text must begin with '{' at character 11 of













<html>

<head>
<title>Forbidden (403)</title>




<!--[if IE]><![endif]-->
<script type="text/javascript">
(function() {
var contextPath = '';
var eventBuffer = [];

function printDeprecatedMsg() {
if (console && console.warn) {
console.warn('DEPRECATED JS - contextPath global variable has been deprecated since 7.4.0. Use `wrm/context-path` module instead.');
}
}

function sendEvent(analytics, postfix) {
analytics.send({
name: 'js.globals.contextPath.' + postfix
});
}

function sendDeprecatedEvent(postfix) {
try {
var analytics = require('jira/analytics');
if (eventBuffer.length) {
eventBuffer.forEach(function(value) {
sendEvent(analytics, value);
});
eventBuffer = [];
}

if (postfix) {
sendEvent(analytics, postfix);
}
} catch(ex) {
eventBuffer.push(postfix);
setTimeout(sendDeprecatedEvent, 1000);
}
}

Object.defineProperty(window, 'contextPath', {
get: function() {
printDeprecatedMsg();
sendDeprecatedEvent('get');
return contextPath;
},
set: function(value) {
printDeprecatedMsg();
sendDeprecatedEvent('set');
contextPath = value;
}
});
})();

</script>
<script>
window.WRM=window.WRM||{};window.WRM._unparsedData=window.WRM._unparsedData||{};window.WRM._unparsedErrors=window.WRM._unparsedErrors||{};
WRM._unparsedData["com.atlassian.plugins.atlassian-plugins-webresource-plugin:context-path.context-path"]="\"\"";
WRM._unparsedData["jira.webresources:feature-flags.feature-flag-data"]="{\"enabled-feature-keys\":[\"com.atlassian.jira.agile.darkfeature.editable.detailsview\",\"nps.survey.inline.dialog\",\"com.atlassian.jira.agile.darkfeature.edit.closed.sprint.enabled\",\"jira.plugin.devstatus.phasetwo\",\"jira.frother.reporter.field\",\"atlassian.rest.xsrf.legacy.enabled\",\"jira.issue.status.lozenge\",\"com.atlassian.jira.config.BIG_PIPE\",\"com.atlassian.jira.projects.issuenavigator\",\"com.atlassian.jira.config.PDL\",\"jira.plugin.devstatus.phasetwo.enabled\",\"atlassian.aui.raphael.disabled\",\"app-switcher.new\",\"frother.assignee.field\",\"com.atlassian.jira.projects.ProjectCentricNavigation.Switch\",\"jira.onboarding.cyoa\",\"com.atlassian.jira.agile.darkfeature.kanplan.enabled\",\"com.atlassian.jira.config.ProjectConfig.MENU\",\"com.atlassian.jira.projects.sidebar.DEFER_RESOURCES\",\"com.atlassian.jira.agile.darkfeature.kanplan.epics.and.versions.enabled\",\"com.atlassian.jira.agile.darkfeature.sprint.goal.enabled\",\"jira.zdu.admin-updates-ui\",\"jira.zdu.jmx-monitoring\",\"sd.new.settings.sidebar.location.disabled\",\"jira.zdu.cluster-upgrade-state\",\"com.atlassian.jira.agile.darkfeature.splitissue\",\"com.atlassian.jira.config.CoreFeatures.LICENSE_ROLES_ENABLED\",\"jira.export.csv.enabled\"],\"feature-flag-states\":{\"jira.spectrum.m1\":true,\"com.atlassian.jira.issuetable.draggable\":true,\"com.atlassian.jira.agile.darkfeature.kanban.hide.old.done.issues\":true,\"jira.jql.suggestrecentfields\":false,\"com.atlassian.jira.agile.darkfeature.optimistic.transitions\":true,\"com.atlassian.jira.issuetable.move.links.hidden\":true,\"jira.renderer.consider.variable.format\":true,\"com.atlassian.jira.agile.darkfeature.kanplan\":false,\"jira.priorities.per.project.jsd\":true,\"jira.instrumentation.laas\":false,\"com.atlassian.jira.sharedEntityEditRights\":true,\"jira.customfields.paginated.ui\":true,\"com.atlassian.jira.agile.darkfeature.edit.closed.sprint\":false,\"jira.create.linked.issue\":true,\"jira.spectrum.m1b\":false,\"com.atlassian.jira.agile.darkfeature.sprint.goal\":false,\"com.atlassian.jira.agile.darkfeature.sidebar.boards.list\":true,\"jira.sal.host.connect.accessor.existing.transaction.will.create.transactions\":true,\"com.atlassian.jira.custom.csv.escaper\":true,\"com.atlassian.jira.plugin.issuenavigator.filtersUxImprovment\":true,\"com.atlassian.jira.agile.darkfeature.kanplan.epics.and.versions\":false,\"jira.quick.search\":true,\"jira.jql.smartautoselectfirst\":false,\"com.atlassian.jira.projects.per.project.permission.query\":true,\"com.atlassian.jira.projects.archiving\":true,\"index.use.snappy\":true,\"jira.priorities.per.project\":true,\"com.atlassian.jira.upgrade.startup.fix.index\":true}}";
WRM._unparsedData["jira.webresources:default-comment-security-level.DefaultCommentSecurityLevelHelpLink"]="{\"extraClasses\":\"default-comment-level-help\",\"title\":\"Commenting on an Issue\",\"url\":\"https://docs.atlassian.com/jira/jcore-docs-0713/Editing+and+collaborating+on+issues#Editingandcollaboratingonissues-restrictacomment\",\"isLocal\":false}";
WRM._unparsedData["com.atlassian.analytics.analytics-client:policy-update-init.policy-update-data-provider"]="false";
WRM._unparsedData["com.atlassian.analytics.analytics-client:programmatic-analytics-init.programmatic-analytics-data-provider"]="false";
WRM._unparsedData["com.onresolve.jira.groovy.groovyrunner:web-item-response-renderer.web-item-actions-data-provider"]="[]";
WRM._unparsedData["jira.webresources:dateFormatProvider.allFormats"]="{\"dateFormats\":{\"meridiem\":[\"AM\",\"PM\"],\"eras\":[\"BC\",\"AD\"],\"months\":[\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"],\"monthsShort\":[\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"],\"weekdaysShort\":[\"Sun\",\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\"],\"weekdays\":[\"Sunday\",\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\"]},\"lookAndFeelFormats\":{\"relativize\":\"true\",\"time\":\"HH:mm\",\"day\":\"EEEE HH:mm\",\"dmy\":\"dd.MM.yyyy\",\"complete\":\"dd.MM.yyyy HH:mm\"}}";
WRM._unparsedData["jira.webresources:avatar-picker.data"]="{}";
WRM._unparsedData["com.atlassian.jira.jira-header-plugin:dismissedFlags.flags"]="{\"dismissed\":[]}";
WRM._unparsedData["com.atlassian.jira.jira-header-plugin:newsletter-signup-tip-init.newsletterSignup"]="{\"signupDescription\":\"Get updates, inspiration and best practices from the team behind Jira.\",\"formUrl\":\"https://www.atlassian.com/apis/exact-target/{0}/subscribe?mailingListId=1401671\",\"signupTitle\":\"Sign up!\",\"signupId\":\"newsletter-signup-tip\",\"showNewsletterTip\":false}";
WRM._unparsedData["com.atlassian.jira.project-templates-plugin:project-templates-plugin-resources.ptAnalyticsData"]="{\"instanceCreatedDate\":\"2018-11-12\"}";
WRM._unparsedData["com.onresolve.jira.groovy.groovyrunner:directIdeaIntegration.idea-editor-data-provider"]="{\"available\":false,\"enabled\":false,\"isExternalIdeaEnabled\":false,\"url\":\"https://localhost:63349\",\"app\":\"JIRA\",\"version\":\"7.13.2\",\"buildNumber\":\"713002\",\"pluginVersion\":\"5.5.3\",\"running\":false,\"canonicalBaseUrl\":\"https://[STRIPPED]\",\"scriptRoots\":[],\"isSystemAdmin\":false,\"hasEditPermissions\":false,\"clustered\":false,\"clusterNodeIds\":[],\"clusterNodeId\":null,\"helpBaseUrl\":\"https://scriptrunner.adaptavist.com/5.5.3\"}";
WRM._unparsedData["com.atlassian.jira.plugins.jira-wiki-editor:wiki-editor-thumbnails.thumbnails-allowed"]="true";
WRM._unparsedData["com.atlassian.jira.plugins.jira-wiki-editor:wiki-editor-resources.help-data"]="{\"showHelp\":true,\"editorDocumentationUrl\":[\"https://docs.atlassian.com/jira/jcore-docs-0713/Visual+editing\"],\"editorDocumentationTitle\":[\"Show me documentation for the visual editor\"]}";
WRM._unparsedData["jira.webresources:user-message-flags.adminLockout"]="{}";
WRM._unparsedData["com.atlassian.plugins.helptips.jira-help-tips:help-tip-manager.JiraHelpTipData"]="{\"anonymous\":true}";
if(window.WRM._dataArrived)window.WRM._dataArrived();</script>
<link type="text/css" rel="stylesheet" href="/s/62a3aeb055811a38fa7cf18cd21c1357-CDN/vvhgmp/713002/6411e0087192541a09d88223fb51a6a0/a069ffa20e4fcefe6fb65c05a1f43a62/_/download/contextbatch/css/_super/batch.css?spectrum=true" data-wrm-key="_super" data-wrm-batch-type="context" media="all">
<link type="text/css" rel="stylesheet" href="/s/8ecd70f84d36ee11dd80dab51577e78d-CDN/vvhgmp/713002/6411e0087192541a09d88223fb51a6a0/f86d9400104ebe05c1060f8838092a9e/_/download/contextbatch/css/atl.general,jira.general,-_super/batch.css?agile_global_admin_condition=true&amp;is-server-instance=true&amp;jag=true&amp;nps-acknowledged=true&amp;spectrum=true" data-wrm-key="atl.general,jira.general,-_super" data-wrm-batch-type="context" media="all">
<link type="text/css" rel="stylesheet" href="/s/1b96698e0568e993f8c973de2de75601-CDN/vvhgmp/713002/6411e0087192541a09d88223fb51a6a0/290dd7ad69c271131d8107b41282d5bd/_/download/contextbatch/css/jira.global,-_super/batch.css?spectrum=true" data-wrm-key="jira.global,-_super" data-wrm-batch-type="context" media="all">
<link type="text/css" rel="stylesheet" href="/s/dbfa9160361595bf23a5d6c563868203-CDN/vvhgmp/713002/6411e0087192541a09d88223fb51a6a0/7.9.9/_/download/batch/com.atlassian.auiplugin:aui-labels/com.atlassian.auiplugin:aui-labels.css" data-wrm-key="com.atlassian.auiplugin:aui-labels" data-wrm-batch-type="resource" media="all">
<link type="text/css" rel="stylesheet" href="/s/2ea6224284b85b9a5bdcbaccecf4e262-CDN/vvhgmp/713002/6411e0087192541a09d88223fb51a6a0/1.0/_/download/batch/jira.webresources:global-static-adgs/jira.webresources:global-static-adgs.css?spectrum=true" data-wrm-key="jira.webresources:global-static-adgs" data-wrm-batch-type="resource" media="all">
<link type="text/css" rel="stylesheet" href="/s/947f1ea935df68ae531974ff53795f00-CDN/vvhgmp/713002/6411e0087192541a09d88223fb51a6a0/1.0/_/download/batch/jira.webresources:global-static/jira.webresources:global-static.css" data-wrm-key="jira.webresources:global-static" data-wrm-batch-type="resource" media="all">
<script type="text/javascript" src="/s/85bb1d2c4dba2a7ab573ad4f8c0b8a8c-CDN/vvhgmp/713002/6411e0087192541a09d88223fb51a6a0/a069ffa20e4fcefe6fb65c05a1f43a62/_/download/contextbatch/js/_super/batch.js?locale=en-UK&amp;spectrum=true" data-wrm-key="_super" data-wrm-batch-type="context" data-initially-rendered></script>
<script type="text/javascript" src="/s/6c5e3c152533f9b247cf83ede2e824b9-CDN/vvhgmp/713002/6411e0087192541a09d88223fb51a6a0/f86d9400104ebe05c1060f8838092a9e/_/download/contextbatch/js/atl.general,jira.general,-_super/batch.js?agile_global_admin_condition=true&amp;is-server-instance=true&amp;jag=true&amp;locale=en-UK&amp;nps-acknowledged=true&amp;spectrum=true" data-wrm-key="atl.general,jira.general,-_super" data-wrm-batch-type="context" data-initially-rendered></script>
<script type="text/javascript" src="/s/163a19cf3cf699bbc00f3aa3b10d0a7d-CDN/vvhgmp/713002/6411e0087192541a09d88223fb51a6a0/e287e7ff5a6bca2d97c6997b2d0b3d12/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en-UK&amp;spectrum=true" data-wrm-key="atl.global,-_super" data-wrm-batch-type="context" data-initially-rendered></script>
<script type="text/javascript" src="/s/b6556cbcb1b126e92ae04f62e759b897-CDN/vvhgmp/713002/6411e0087192541a09d88223fb51a6a0/290dd7ad69c271131d8107b41282d5bd/_/download/contextbatch/js/jira.global,-_super/batch.js?locale=en-UK&amp;spectrum=true" data-wrm-key="jira.global,-_super" data-wrm-batch-type="context" data-initially-rendered></script>
<link type="text/css" rel="stylesheet" href="/s/6d6c93d354eb2c805fb3c23cb5697e0f-CDN/vvhgmp/713002/6411e0087192541a09d88223fb51a6a0/df8aff3c439c3b9687f0a4ab43d57a8a/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css?spectrum=true" data-wrm-key="jira.global.look-and-feel,-_super" data-wrm-batch-type="context" media="all">

<script type="text/javascript" src="/rest/api/1.0/shortcuts/713002/2a9f814c9b70f08f9d4ca415c9a54aba/shortcuts.js"></script>


<meta name="application-name" content="JIRA" data-name="jira" data-version="7.13.2">
</head>
<body id="jira" class="aui-layout aui-style-default page-type-message" data-version="7.13.2" >
<div class="aui-page-panel"><div class="aui-page-panel-inner">
<section class="aui-page-panel-content">
<header class="aui-page-header"><div class="aui-page-header-inner">
<div class="aui-page-header-main">
<h1>Forbidden (403)</h1>
</div><!-- .aui-page-header-main -->
</div><!-- .aui-page-header-inner --></header><!-- .aui-page-header -->
<div class="aui-message aui-message-warning warning">
<p>Encountered a <code>&quot;403 - Forbidden&quot;</code> error while loading this page.</p>
<p>Basic Authentication Failure - Reason : AUTHENTICATION_DENIED</p>
<p><a href="/secure/MyJiraHome.jspa">Go to Jira home</a></p>
</div>
</section><!-- .aui-page-panel-content -->
</div><!-- .aui-page-panel-inner --></div><!-- .aui-page-panel -->
</body>
</html>

at org.codehaus.jettison.json.JSONTokener.syntaxError(JSONTokener.java:439)
at org.codehaus.jettison.json.JSONObject.<init>(JSONObject.java:169)
at org.codehaus.jettison.json.JSONObject.<init>(JSONObject.java:266)
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient.extractErrors(AbstractAsynchronousRestClient.java:212)
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$2.apply(AbstractAsynchronousRestClient.java:175)
... 15 more

(Jira v7.13.2)

 

To improve this, could either the Server return an JSON error message via the REST API, or the JRJC client (AbstractAsynchronousRestClient.extractErrors(AbstractAsynchronousRestClient.java:212)) detect the type (JSON, HTML) of the returned content and parse it accordingly?

 

0 comments

Comment

Log in or Sign up to comment
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you