axios: Getting 400 Bad Request in v1.2.0 with same code that returned 200 with v0.27.2

Describe the bug

We are making a get request to an endpoint that works great, returning 200 OK with v0.27.2 of axios, but when we upgrade to 1.0.0 or to the latest 1.2.0, we get 400 Bad requests.

To Reproduce

// run with node index.js

(async () => {
  const instance = axios.create({
    baseURL: 'https://DOMAIN_SANITIZED/api/internal/v1',
    timeout: 1000,
    headers: { 'Authorization': 'Bearer SANITIZED' }
  });


  const response = await instance.get('/request/path/sanitized?q={"merchantId":"SANITIZED 32 CHAR GUID","scheduleType":"CLASS","isDeleted":false}');


  console.log(response.data);
  console.log(response.status);
  //console.log(response.statusText);
  //console.log(response.headers);
  //console.log(response.config);

})();

Code snippet

No response

Expected behavior

We expect the latest version to work the same as 0.27.2.

Axios Version

1.2.0

Adapter Version

UNKNOWN

Browser

N/A

Browser Version

N/A

Node.js Version

16.17.0

OS

macOS 13.0.1 M1

Additional Library Versions

No additional libs. The code snippet included is a minimal reproduceable example, which has been sanitized.

Additional context/Screenshots

We are unable to include the exact payload that caused the problem since it requires authentication.  We suspect/guess that maybe it is some kind of URL encoding issue that may have been introduced in v1.0.0.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 4
  • Comments: 16 (10 by maintainers)

Commits related to this issue

Most upvoted comments

I just updated to 1.2.1 from 1.1.3 and am getting the same end of file error:

(node:17800) UnhandledPromiseRejectionWarning: Error: unexpected end of file
    at AxiosError.from (C:\Data\ZENDev\multisigapp\node_modules\axios\dist\node\axios.cjs:785:14)
    at BrotliDecompress.handleStreamError (C:\Data\ZENDev\multisigapp\node_modules\axios\dist\node\axios.cjs:2696:29)
    at BrotliDecompress.emit (node:events:525:35)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)

Both myself and my users have been reporting Axios errors on 1.2.1. I’ll dig up some more detail shortly. Regards Jochen

(node:17800) UnhandledPromiseRejectionWarning: Error: unexpected end of file
    at AxiosError.from (C:\Data\ZENDev\multisigapp\node_modules\axios\dist\node\axios.cjs:785:14)
    at BrotliDecompress.handleStreamError (C:\Data\ZENDev\multisigapp\node_modules\axios\dist\node\axios.cjs:2696:29)
    at BrotliDecompress.emit (node:events:525:35)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)

Seems like these AxiosError: unexpected end of file problems are fixed in axios@1.2.2

@jamesmortensen can you check, and if confirmed, close the issue?