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

fix: use 'errors.getMessage' to determine error message in AxiosWrapper #958

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

dkwon17
Copy link
Contributor

@dkwon17 dkwon17 commented Oct 20, 2023

What does this PR do?

I noticed that the Bearer Token Authorization is required message exists in err.response.data.message, rather than err.message:
Screenshot from 2023-10-20 12-55-58

What issues does this PR fix or reference?

Related to 401/403 issues.

Is it tested? How?

Random 401 issues can be simulated by adding this git patch to the dashboard:

diff --git a/packages/dashboard-backend/src/routes/api/helpers/getToken.ts b/packages/dashboard-backend/src/routes/api/helpers/getToken.ts
index 59e8d76f..71a5dd62 100644
--- a/packages/dashboard-backend/src/routes/api/helpers/getToken.ts
+++ b/packages/dashboard-backend/src/routes/api/helpers/getToken.ts
@@ -18,6 +18,11 @@ const authorizationBearerPrefix = /^Bearer /;
 
 export function getToken(request: FastifyRequest): string {
   const authorization = request.headers?.authorization;
+
+  if (Math.random() < 0.4) {
+    throw createFastifyError('FST_UNAUTHORIZED', 'Bearer Token Authorization is required', 401);
+  }
+
   if (!authorization || !authorizationBearerPrefix.test(authorization)) {
     throw createFastifyError('FST_UNAUTHORIZED', 'Bearer Token Authorization is required', 401);
   }

When the 401 errors occur, there should be Retrying request ... warnings in the console:
Screenshot from 2023-10-20 15-44-24

Release Notes

Docs PR

@che-bot
Copy link
Contributor

che-bot commented Oct 20, 2023

Click here to review and test in web IDE: Contribute

@dkwon17 dkwon17 requested a review from tolusha October 20, 2023 19:56
@github-actions
Copy link

Docker image build succeeded: quay.io/eclipse/che-dashboard:pr-958

@openshift-ci
Copy link

openshift-ci bot commented Oct 20, 2023

@dkwon17: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/v11-dashboard-happy-path db18767 link true /test v11-dashboard-happy-path

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

Copy link
Contributor

@tolusha tolusha left a comment

Choose a reason for hiding this comment

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

Nice catch.

@ibuziuk
Copy link
Member

ibuziuk commented Oct 23, 2023

@dkwon17 once merged, could you please cherry-pick the fix for 3.10 ?

@openshift-ci
Copy link

openshift-ci bot commented Oct 23, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: akurinnoy, dkwon17, ibuziuk, olexii4, tolusha

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@dkwon17 dkwon17 merged commit 6ed8cc0 into main Oct 23, 2023
13 of 14 checks passed
@dkwon17 dkwon17 deleted the getAxiosErrorMsg branch October 23, 2023 13:08
@devstudio-release
Copy link

Build 3.10 :: dashboard_3.x/370: Console, Changes, Git Data

@devstudio-release
Copy link

Build 3.10 :: dashboard_3.x/371: Console, Changes, Git Data

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

Build 3.10 :: get-sources-rhpkg-container-build_3.x/4870: FAILURE

dashboard : 3.x :: Failed in : BREW:BUILD/STATUS:UNKNOWN
FAILURE:; copied to quay

@devstudio-release
Copy link

@devstudio-release
Copy link

Build 3.10 :: get-sources-rhpkg-container-build_3.x/4871: FAILURE

dashboard : 3.x :: Failed in : quay.io/devspaces/dashboard-rhel8:3.10-40
FAILURE:; copied to quay

@devstudio-release
Copy link

Build 3.11 :: dashboard_3.x/372: Console, Changes, Git Data

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

Build 3.11 :: get-sources-rhpkg-container-build_3.x/4886: FAILURE

dashboard : 3.x :: Failed in : BREW:BUILD/STATUS:UNKNOWN
FAILURE:; copied to quay

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

Successfully merging this pull request may close these issues.

7 participants