mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
IDEA-216363 Report "field invisible to anonymous user" errors as invalid credentials in JIRA
GitOrigin-RevId: 64e89cc4599d33e46f6732a5d03f2b6eac770327
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e338e40dd6
commit
b2875bdf04
@@ -15,6 +15,7 @@ jira.failure.no.state.update=Task state cannot be updated in JIRA versions prior
|
||||
jira.failure.no.time.spent=Time spent cannot be updated in JIRA versions prior 5.0.
|
||||
|
||||
jira.failure.captcha=Login failed. Enter captcha in web-interface.
|
||||
jira.failure.email.address=Login failed. Check your email address.
|
||||
|
||||
## YouTrack
|
||||
youtrack.default.query=for: me sort by: updated #Unresolved
|
||||
|
||||
@@ -311,8 +311,15 @@ public class JiraRepository extends BaseRepositoryImpl {
|
||||
JsonObject object = GSON.fromJson(entityContent, JsonObject.class);
|
||||
if (object.has("errorMessages")) {
|
||||
String reason = StringUtil.join(object.getAsJsonArray("errorMessages"), " ");
|
||||
// something meaningful to user, e.g. invalid field name in JQL query
|
||||
// If anonymous access is enabled on server, it might reply only with a cryptic 400 error about inaccessible issue fields,
|
||||
// e.g. "Field 'assignee' does not exist or this field cannot be viewed by anonymous users."
|
||||
// Unfortunately, there is no better way to indicate such errors other than by matching by the error message itself.
|
||||
LOG.warn(reason);
|
||||
if (statusCode == HttpStatus.SC_BAD_REQUEST && reason.contains("cannot be viewed by anonymous users")) {
|
||||
// Oddly enough, in case of JIRA Cloud issues are access anonymously only if API Token is correct, but email is wrong.
|
||||
throw new Exception(isInCloud() ? TaskBundle.message("jira.failure.email.address") : TaskBundle.message("failure.login"));
|
||||
}
|
||||
// something meaningful to user, e.g. invalid field name in JQL query
|
||||
throw new Exception(TaskBundle.message("failure.server.message", reason));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user