Skip to content

fix: catch null preferences#2123

Closed
jaulz wants to merge 1 commit intohapijs:masterfrom
jaulz:patch-1
Closed

fix: catch null preferences#2123
jaulz wants to merge 1 commit intohapijs:masterfrom
jaulz:patch-1

Conversation

@jaulz
Copy link

@jaulz jaulz commented Sep 17, 2019

I noticed that when using a when construction the preferences are null:
https://github.com/hapijs/joi/blob/master/lib/base.js#L356

@hueniverse
Copy link
Contributor

Thanks but I need an example reproducing it.

@jaulz jaulz closed this Sep 18, 2019
@jaulz jaulz deleted the patch-1 branch September 18, 2019 06:04
@hueniverse hueniverse self-assigned this Sep 18, 2019
@hueniverse hueniverse added the non issue Issue is not a problem or requires changes label Sep 18, 2019
@jaulz
Copy link
Author

jaulz commented Sep 18, 2019

Hm, I thought I found that I was doing something wrong but I constantly see the same issue:

Cannot read property 'errors' of null

Unfortunately, I cannot really reproduce it but it seems to be related to when constructions. I'm still trying to find the root cause but it's difficult. If I console.log(item) in keys I get this:

  console.log node_modules/@hapi/joi/lib/types/keys.js:107
    undefined

Maybe you have an idea? I see this issue by the way when using hapi and pass invalid payloads (some keys not set) to the routes.

@jaulz
Copy link
Author

jaulz commented Sep 18, 2019

Okay, I set abortEarly: false in my global validation rules of hapi and when I set it back to true it works as expected. Still, I am not able to reproduce it in codesandbox which is very strange...

@jaulz
Copy link
Author

jaulz commented Sep 18, 2019

@hueniverse sorry for spamming you but I could eventually create an example which reproduces the issue:
https://codesandbox.io/s/youthful-meitner-k26nc

It seems to be related to preferences but maybe I just did not understand how they work. As soon as I remove the preferences from line 14 it works as expected. Though, eventually I would like to have a global Joi object which has { errors: { label: 'path' } }. I will also try to dive more into the issue tomorrow...

@hueniverse
Copy link
Contributor

Thanks. Will look into this later today.

@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

non issue Issue is not a problem or requires changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants