So the latest release of type-is package which is used in node-req has a new check in tryNormalizeType function:
if (typeof value !== 'string') {
return null
}
The release was made today.
Unfortunately, it brakes adonis body parser since body type check stops working and returns false on all types (aka this._isType(request, this.jsonTypes)).
By default node-req tries to get the latest type-is version and hence all the users who made a fresh adonis install in the last few hours wouldn't be able to get a request body.
I'm not sure whether this issue should be in node-req (by the way. npm page has a wrong github repo link) or in body-parser repo. So I'll post it here since it is the main adonis repo.
"@adonisjs/framework": "^5.0.13",
"@adonisjs/bodyparser": "^2.0.9",
10.15.3
request.all() or any other request
To reproduce, make a fresh adonis install and do a POST with any body (I tested on application/json.
@thetutlage @RomainLanz might worth taking a look ASAP… The quick fix would be to set a node-req#type-is dependency on stictly to 1.6.16 version.
However, as I mentioned above the link to the node-req repo @ npm is broken so I'm not sure which node-req repo is the proper one…
I've been trying for 6 hours to see what the problem was. I thought it was the only 😢 Thank you @SAGV
I'm having the same problem.
The quick fix would be to set a node-req#type-is dependency on stictly to 1.6.16 version.
where do I set this?
@SAGV okay I understand it now. I though that I could set node-req#type-is: '1.6.16' in package.json
it should be
"type-is": "^1.6.16",
It's weird that they released a breaking change in a patch version. Looking into it
Thanks @thetutlage ! Really stuck and we have to go love today :(, if you can even give me a quick fix, I will use that to at-least get through today and tomorrow!
Remove node_modules and package-lock.json file and run npm i again. Should be good to go after that.
Thanks @SAGV for bringing it to the notice. If you guys can confirm the fix, I will close this issue
So strange, all my post body is empty, why
Thanks @SAGV for bringing it to the notice. If you guys can confirm the fix, I will close this issue
Awesome @thetutlage it works now!
Thanks 😄
Thanks, @thetutlage !
where do I set this?
@jericopulvera well, this bug was already fixed while I was sleeping. However, if you face similar issues with a different package, you can force-set sub-dependency version either with yarn resolutions or with npm force resolutions like this in package.json:
"resolutions": {
"@adonisjs/framework/node-req/type-is": "1.6.16"
},
It's weird that they released a breaking change in a patch version. Looking into it
@thetutlage it was unintentional; no one reported it to the type-is repo until a few hours ago, and so I pushed 1.6.18 with it fixed. Sorry for the trouble, though I didn't realize until just recently that it was a breaking change. I added a test suite to the repo as well for this case to prevent it from regressing again.
Body type checking in request break its always return false, I don't have idea its related to type-is.
Previously it was working.
const isJson = request.is(['json']);
Are you setting the Content-type as application/json for the request?
thanks @thetutlage
Yes, I am setting.
It is previously working. today, I did npm update and its break. this updated
@adonisjs/framework 5.0.09 to 5.0.13
@adonisjs/bodyparser 2.0.5 to 2.0.9
I also tried
request.is(['application/*'])
But bad luck its also returning false
Now it starts working, I run again npm install
I don't have an idea about what happened.
thanks @thetutlage
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Thanks @SAGV for bringing it to the notice. If you guys can confirm the fix, I will close this issue