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

chore(deps): Update axios to fix CVE #1167

Merged
merged 1 commit into from Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
94 changes: 80 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -17,7 +17,7 @@
"@redhat-cloud-services/host-inventory-client": "^1.2.2",
"@scalprum/react-core": "^0.4.1",
"@unleash/proxy-client-react": "^3.5.0",
"axios": "^0.21.4",
"axios": "^0.28.0",
"jest-environment-jsdom": "^29.7.0",
"p-all": "^5.0.0",
"query-string": "^6.14.1",
Expand Down
8 changes: 3 additions & 5 deletions src/Utilities/axiosInterceptors.js
Expand Up @@ -9,18 +9,16 @@ const axiosInstance = axios.create();
export function errorInterceptor(err) {

if (!axios.isCancel(err)) {
const { response } = { ...err };

const { response, isAxiosError } = { ...err };

if (response && isAxiosError) {
if (response && err.isAxiosError) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

For my understanding, what was the issue here?

Copy link
Member Author

Choose a reason for hiding this comment

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

In the new version of axios

const { response, isAxiosError } = { ...err }
console.log(isAxiosError); // prints "undefined"
console.log(err.isAxiosError); // prints "true"

It seems like by copying the object the destructuring and direct property access behave differently.

const { status, statusText, data } = response;

if (!status) {
return err;
} else {
const genericError = {
title:
'There was an error getting data'
title: 'There was an error getting data'
};

const result = { ...genericError, detail: data.error || statusText, status };
Expand Down