Joi: Uncaught Error: Buffer is not included

Created on 28 Sep 2017  路  9Comments  路  Source: sideway/joi

Context

  • node version: v7.2.1
  • npm version: 3.10.10
  • joi version: 10.6.0
  • used with: react-validation-mixin v4.2.0

What are you trying to achieve or the steps to reproduce ?

I'm trying to customize the error message for a boolean() validation.

const schema = Joi.object().keys({
     a: Joi.boolean().label('Are you sure?'), 
   });

schema.validate({
  a: null,
});

Which result you had ?

Uncaught Error: Buffer is not included.
    at new Buffer (common.cff945c3548744033d3c.js:42239)
    at Object.internals.escapeHtmlChar (common.cff945c3548744033d3c.js:43381)
    at Object.exports.escapeHtml (common.cff945c3548744033d3c.js:43353)
    at Object.exports.escapeHtml (common.cff945c3548744033d3c.js:42111)
    at common.cff945c3548744033d3c.js:44464
    at String.replace (<anonymous>)
    at _class.toString (common.cff945c3548744033d3c.js:44460)
    at processErrors (common.cff945c3548744033d3c.js:44502)
    at Object.exports.process (common.cff945c3548744033d3c.js:44524)
    at _class._validateWithOptions (common.cff945c3548744033d3c.js:44072)

What did you expect ?

/*
ValidationError: "Are you sure?" must be a boolean
*/
non issue

Most helpful comment

Woowwww guys, you really went far beyond my words... I had to go back and read my comments on joi-browser just to see if I wrote something under the effect of drugs that I don't remember. I did never mean to blame you or look down on you, I apologize if that's what I made you feel.

Let me be clear, I really appreciate your work, much more than what you think, you make my life easier than what it would be without you, and I appreciate IT even more due to the fact that many of you guys do IT for the joi of IT.

I understand you have your point when you refuse to take action on some user's request and I totally agree with you when you say "at least provide me any means to easily reproduce it"

That being said I will try to find some time to provide you the means to reproduce the problem

@DavidTPate I have already tried the feross/buffer solution and the Buffer issue was still there. Thanks anyways for the hint ;)

All 9 comments

So it appears that you are utilizing WebPack and using Joi on the client side, there doesn't appear to be anything incorrect on the Joi side here as it works in our target environment (Node) we do not target client side support. The actual line throwing this issue is in Hoek which again does not target the browser but instead targets Node (that line is correct, there would appear to be an issue with your environment being created during bundling).

It would appear to be a bundling issue. You can see some common fixes for bundling issues that have come up in #665 but they are unlikely to help with your issue here.

@jmgarciaromero I saw your comment on joi-browser and I don't think it's worth going off-topic there, so I'll answer here.

I'm very dismissive of the entitlement of people that consider that everything should just work whatever their use of the library, and I really couldn't care less if it's an unpopular opinion. I have exposed my requirements about bundling many times, and not a single person found a solution, or nobody tried. So I do consider it your (as app builders) problem. And I'm very thankful for joi-browser even though I don't think that's the right solution.

Despite what you may think, I'm doing the best I can to take browsers into consideration when I'm developing joi, and I forbade myself from doing many things because of that, some of the design decisions I took in what joi currently is are because of browsers, so don't think for a second I take pleasure in creating a struggle for that community.

And yes, sometimes I lack empathy, working on that, I'm only human, but if someone comes to a module that is clearly for node, asking for webpack help, without providing me any means to reproduce, unless I spend half an hour or so setting up a webpack environment to finally get to the issue, I take it very personally that my time has no value for that person, so don't expect anything in return.

As for your issue at hand, is there any chance that hoek is already bundled somewhere else without the Buffer ? Can you provide a minimal thing that I can clone and use to see the problem ?

I take it very personally that my time has no value for that person, so don't expect anything in return.

Definitely this. I wish I got paid just to work on OSS stuff all day but sadly I do not. I do it with my own time because I like to help out.

I have no clue if this would work, but it would appear angry that Buffer isn't included. I see there's webpack/node-libs-browser that references feross/buffer for a buffer implementation for WebPack. Maybe forcing that dependency would work?

Woowwww guys, you really went far beyond my words... I had to go back and read my comments on joi-browser just to see if I wrote something under the effect of drugs that I don't remember. I did never mean to blame you or look down on you, I apologize if that's what I made you feel.

Let me be clear, I really appreciate your work, much more than what you think, you make my life easier than what it would be without you, and I appreciate IT even more due to the fact that many of you guys do IT for the joi of IT.

I understand you have your point when you refuse to take action on some user's request and I totally agree with you when you say "at least provide me any means to easily reproduce it"

That being said I will try to find some time to provide you the means to reproduce the problem

@DavidTPate I have already tried the feross/buffer solution and the Buffer issue was still there. Thanks anyways for the hint ;)

Everything was not entirely for you specifically, I was addressing the general concern of my rejections of webpack issues, sorry if it came out appearing as if you were under fire. As you can see, it led the commenter right after you to believe I'm anti-webpack or something, which I'm not. That makes one more angry comment from me to point people to if that is ever being discussed again :p

I know text is a very poor communicator of tone, but definitely no offense taken here @jmgarciaromero. I don't think you reply was done in poor taste or anything even close to that.

I have already tried the feross/buffer solution and the Buffer issue was still there. Thanks anyways for the hint ;)

Darn! I'm really lost as to what the issue is then, I'm sure it will be very interesting once the solution is found.

v12 or v13 (if you manage to build this one) will probably help you have a build that works, but that shouldn't have been the solution.

I have built joi-browser using joi versions v12 and v13 and after some testing the "Buffer not included" error is gone!

I need to do some more testing because I noticed the email validation does not work using v12 and v13, I'm not sure if it is a side effect of the "Buffer not included" fix or it is another bundling issue...

Probably another issue, I don't think there's been a release of it since then.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sergibondarenko picture sergibondarenko  路  3Comments

REBELinBLUE picture REBELinBLUE  路  3Comments

kailashyogeshwar85 picture kailashyogeshwar85  路  4Comments

chrisegner picture chrisegner  路  4Comments

Taxi4you picture Taxi4you  路  3Comments