question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Breaking change in validateStatus parameter

See original GitHub issue

Problem:

This is what README.md says about validateStatus parameter:

validateStatus defines whether to resolve or reject the promise for a given HTTP response status code. If validateStatus returns true (or is set to null or undefined), the promise will be resolved; otherwise, the promise will be rejected.

This parameter supports (as specified) undefined in 0.18.x but it does not work properly in 0.19.0 despite the documentation does not warn about this change.

Affects version: 0.19.0 (latest)

Steps to reproduce it: Set validateStatus property to undefined value and request anything that returns 404 Not Found.

Current behavior: It uses the standard validation function (that only accepts 2XX status codes); rejecting any non successful response.

Expected behavior: It should accept any status code received from server as null value does.

Reproducible scenario:

const axios = require('axios'); // v0.19.0

axios
  .get('https://example.com/404', { validateStatus: undefined })
  .catch(console.error);

// output: axios error due to 404 not found

Solution:

Analyze where the bug has been added and fix it.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
sergioregueiracommented, Jan 18, 2020

Indeed, the README.md still says undefined is a valid value for that parameter.

1reaction
sergioregueiracommented, Jan 18, 2020

I do not agree #2545 fixes this problem. The behavior for validateStatus was modified from 0.18.x to 0.19.x without any warning (release notes), so this should be the procedure:

  1. Restore the previous behavior releasing a patch version (0.19.x) to maintain backward compatibility.
  2. Change the behavior to the new one in next minor version (0.20.x) informing the user about this breaking change.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a way I can call an API from an api in ... - Stack Overflow
It is a breaking change from axios version 0.19. If you would like to add a parameter to a request you have to...
Read more >
axios - npm
Until axios reaches a 1.0 release, breaking changes will be released with a new minor version. For example 0.5.1 , and 0.5.4 will...
Read more >
axios/CHANGELOG.md - UNPKG
18, Breaking changes: 19, - New toFormData helper function that allows the implementor to pass an object and allow axios to convert it...
Read more >
[SOLVED] Call contract got this error , what happend?
the link is broken. you should edit the target :wink: ... Hi @noandrea, is the https://compiler.aepps.com should be seted the parameter ...
Read more >
axios中文网
`transformRequest` allows changes to the request data before it is sent to ... `params` are the URL parameters to be sent with the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found