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: when err.code is not numeric or doesnot exist take err.response.… #764

Conversation

naira-petrosyan-m
Copy link

@naira-petrosyan-m naira-petrosyan-m commented Feb 12, 2024

…status instead

Description

GCP thrown err['code'] is a numeric value, while axios.head thrown err['code'] is a string name, e.g. BAD_REQUEST and it has a numeric err.response.status. Change includes checking if there is no err['code'] or it is not numeric take err.response.status otherwise take the err['code'].

Relates to issue SNOW-975540
and PR SNOW-975781

Checklist

  • Format code according to the existing code style (run npm run lint:check -- CHANGED_FILES and fix problems in changed code)
  • Create tests which fail without the change (if possible)
  • Make all tests (unit and integration) pass (npm run test:unit and npm run test:integration)
  • Extend the README / documentation and ensure is properly displayed (if necessary)
  • [] Provide JIRA issue id (if possible) or GitHub issue id in commit message

@naira-petrosyan-m naira-petrosyan-m requested a review from a team as a code owner February 12, 2024 14:55
Copy link

github-actions bot commented Feb 12, 2024

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@@ -178,7 +178,7 @@ function GCSUtil(httpclient, filestream) {
encryptionMetadata
);
} catch (err) {
const errCode = err['code'] ? err['code'] : err.response.status;
const errCode = !err['code'] || isNaN(err['code']) ? err.response.status : err['code'];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @naira-petrosyan-m. Thank you for your proposal. I tried to verify your code and in my opinion it could failed on for example boolean true. What do you think about:
!isNaN(err['code']) && !isNaN(parseInt(err['code'])) ? err['code'] : err.response.status ??

Copy link
Author

@naira-petrosyan-m naira-petrosyan-m Feb 13, 2024

Choose a reason for hiding this comment

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

@sfc-gh-pmotacki I just thought that err.code wouldn't be a Boolean value in any case, but sure I can change the condition to include parseInt.

Copy link
Author

Choose a reason for hiding this comment

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

@sfc-gh-pmotacki fyi I have pushed the update above.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you @naira-petrosyan-m. The code is correct now. I've run tests on your branch and got failed result. Could you rebase to master branch and verify code using 'npm run lint:check' please.

Copy link
Author

Choose a reason for hiding this comment

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

@sfc-gh-pmotacki my branch is opened from the "gcpoperationerror" branch, and when rebasing with master it gives a lot of conflicts as when rebasing master into "gcpoperationerror". This is what I get when running the lint checking command.

Screenshot 2024-02-16 at 14 16 52

@naira-petrosyan-m naira-petrosyan-m force-pushed the bugfix/axios-returning-non-numeric-err-code branch from c8e2e81 to 1665e1a Compare February 13, 2024 10:59
@naira-petrosyan-m
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

* SNOW-1064052 - fix PUT files with wildcards on Windows
@sfc-gh-pmotacki
Copy link
Collaborator

Hello @naira-petrosyan-m. After detect and fix bug in master branch it is needed to rebase branch with master. Can you rebase please?

@naira-petrosyan-m naira-petrosyan-m force-pushed the bugfix/axios-returning-non-numeric-err-code branch from 1665e1a to 569af67 Compare February 23, 2024 09:32
@naira-petrosyan-m
Copy link
Author

Hello @naira-petrosyan-m. After detect and fix bug in master branch it is needed to rebase branch with master. Can you rebase please?

@sfc-gh-pmotacki I have rebased with master

@sfc-gh-pmotacki sfc-gh-pmotacki merged commit c79d086 into snowflakedb:gcpoperationerror Feb 23, 2024
1 check passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 23, 2024
@sfc-gh-pmotacki
Copy link
Collaborator

Thank you one more time @naira-petrosyan-m

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

Successfully merging this pull request may close these issues.

3 participants