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

Since update from 0.21.4 getting "Invalid Payload: Error: Request failed with status code 400" #4367

Closed
Shaquu opened this issue Jan 3, 2022 · 5 comments

Comments

@Shaquu
Copy link

Shaquu commented Jan 3, 2022

Describe the bug

Since I updated from 0.21.4 I am getting rejections from my UniFi server.

As an axios client, I receive Invalid Payload: Error: Request failed with status code 400
On the server, I see [https] 4ms 404 POST /auth/login SyntaxError: Unexpected end of JSON input

I have compared 0.21.4 request log to 0.24.0 and nothing has changed.

To Reproduce

To reproduce you need UDM machine and node-red node installed https://github.com/NRCHKB/node-red-contrib-unifi-os/tree/0.5.3

Axios.interceptors.request.use(config => console.log(config))
{
    headers: {
        common: {
            Accept: 'application/json, text/plain, */*'
        },
        delete: {},
        get: {},
        head: {},
        post: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        put: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        patch: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        'Content-Length': 15
    },
    transformRequest: [
        [Function: transformRequest]
    ],
    transformResponse: [
        [Function: transformResponse]
    ],
    timeout: 0,
    adapter: [Function: httpAdapter],
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    maxBodyLength: -1,
    httpsAgent: Agent {
        _events: [Object: null prototype] {
            free: [Function(anonymous)],
            newListener: [Function: maybeEnableKeylog]
        },
        _eventsCount: 2,
        _maxListeners: undefined,
        defaultPort: 443,
        protocol: 'https:',
        options: [Object: null prototype] {
            rejectUnauthorized: false,
            keepAlive: true,
            path: null
        },
        requests: [Object: null prototype] {},
        sockets: [Object: null prototype] {},
        freeSockets: [Object: null prototype] {},
        keepAliveMsecs: 1000,
        keepAlive: true,
        maxSockets: Infinity,
        maxFreeSockets: 256,
        scheduling: 'lifo',
        maxTotalSockets: Infinity,
        totalSocketCount: 0,
        maxCachedSessions: 100,
        _sessionCache: {
            map: {},
            list: []
        },
        [Symbol(kCapture)]: false
    },
    validateStatus: [Function: validateStatus],
    transitional: {
        silentJSONParsing: true,
        forcedJSONParsing: true,
        clarifyTimeoutError: false
    },
    method: 'post',
    url: 'https://192.168.1.1/api/auth/login',
    data: {
        username: 'user',
        password: 'pass'
    }
}

Expected behavior

It should work :)

Environment

  • Axios Version (0.21.4 is working, >0.21.4 and <= 0.24.0 is failing)
  • Node.js Version 16.11.0
  • OS: Windows 11, Raspbian

Additional context/Screenshots

nah

@Shaquu
Copy link
Author

Shaquu commented Jan 3, 2022

I just noticed.
On 0.21.4 Content-Length is correct but on 0.22.0+ is not

@Shaquu
Copy link
Author

Shaquu commented Jan 3, 2022

Caused by #2880

@Shaquu Shaquu closed this as completed Jan 3, 2022
@vojvodics
Copy link

@Shaquu Is this fixed? I had similar issues with 0.24.0 and 0.25.0. How did you fix this?

@Shaquu
Copy link
Author

Shaquu commented Jan 21, 2022

@vojvodics For some reason I had few lines of code generating length header manually.
I removed it and let axios handle it and it started to work!

If you still have that problem and you have a steps etc I could help to debug.

@vojvodics
Copy link

Thanks for offering help, I'll try to make a reproduction repo

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

No branches or pull requests

2 participants