Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARC-1429: Return 404 if Jira has been renamed. #1268

Merged
merged 9 commits into from
Jun 16, 2022

Conversation

atrigueiro
Copy link
Contributor

@atrigueiro atrigueiro commented Jun 15, 2022

This is closely related to #1193

Because we don't listen to callbacks from Jira when an instance is renamed we end up making requests to the old and new Jira hosts.

We obviously want to treat this better in the future and disable suspended/renamed installations, but for now, this is a better way for us to track this.

I'll also update the Vacuuming page to include this scenario.

@atrigueiro atrigueiro requested a review from a team as a code owner June 15, 2022 00:39
krazziekay
krazziekay previously approved these changes Jun 15, 2022
…1429-sentry-error-405-s-from-renamed-jira-hosts
… github.com:atlassian/github-for-jira into ARC-1429-sentry-error-405-s-from-renamed-jira-hosts
mboudreau
mboudreau previously approved these changes Jun 15, 2022
try {
await axios.get("/status", { baseURL });
} catch (e) {
if (e.response.status === 503) {
logger.info(`503 from Jira: Jira instance '${baseURL}' has been deactivated, is suspended or does not exist. Returning 404 to our application.`);
error.response.status = 404;
}
if (e.response.status === 302) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use else/if instead of if

Copy link
Contributor Author

@atrigueiro atrigueiro Jun 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I use else if I will have to define another else at the end, but there's nothing else I want to do there. Do I just do else { return; } ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else if doesn't force to have else at the end, so skip else if not required

Copy link
Contributor Author

@atrigueiro atrigueiro Jun 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooo nice I didn't know that, I thought else was required. Thanks Harminder, just updated :)

@@ -147,13 +147,16 @@ const instrumentRequest = (response) => {
const instrumentFailedRequest = (baseURL: string, logger: Logger) => {
return async (error: AxiosError) => {
instrumentRequest(error?.response);
if (error.response?.status === 503) {
if (error.response?.status === 503 || error.response?.status === 405) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this should be feature-flagged...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we are changing the behaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm considering it fine because of the comment below.

try {
await axios.get("/status", { baseURL });
} catch (e) {
if (e.response.status === 503) {
logger.info(`503 from Jira: Jira instance '${baseURL}' has been deactivated, is suspended or does not exist. Returning 404 to our application.`);
error.response.status = 404;
} else if (e.response.status === 302) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and this one too...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but probably not a big deal cause this is error handling

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think it's ok because I'm just adding more logging to an error that is already being thrown. If these conditions aren't met, we will reject it anyways on line 163.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants