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

prerequisite returning empty string yields null on the pre object of request #3662

twhitbeck opened this issue Oct 26, 2017 · 5 comments
breaking changes Change that can breaking existing code bug Bug or defect


Copy link

twhitbeck commented Oct 26, 2017

Are you sure this is an issue with hapi or are you just looking for some help?

Definitely with hapi, although I don't know this is a bug or just undocumented behavior. It's unexpected, at the very least.

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

When a route prerequisite replies with an empty string, the resulting property assigned to request.pre is null, not the empty string as I was expecting.

This is because of


Lines 82 to 87 in ec5eaca

if (source === null ||
source === undefined ||
source === '') {
source = null;

What was the result you received?


What did you expect?

empty string


  • node version: 8.8.0
  • hapi version: 16.6.2
  • os: Debian
@hueniverse hueniverse self-assigned this Oct 26, 2017
@hueniverse hueniverse added non issue Issue is not a problem or requires changes bug Bug or defect and removed non issue Issue is not a problem or requires changes labels Oct 26, 2017
@hueniverse hueniverse reopened this Oct 26, 2017
Copy link

@hueniverse is this a bug as in it should return ''? If so would you take a PR?

Copy link

Marsup commented Oct 27, 2017

He assigned himself, unlikely.

Copy link

totally missed that, don't mind me, carry on ^^

Copy link

I am not sure yet. This came up in nes as well where empty payload is sent as null. I need to come up with a consistent way to address it. I think I am not going to force '' into null anymore, but still treat both as empty payload.

@hueniverse hueniverse added this to the 17.0.0 milestone Oct 28, 2017
@hueniverse hueniverse added the breaking changes Change that can breaking existing code label Oct 28, 2017
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.
breaking changes Change that can breaking existing code bug Bug or defect
None yet

No branches or pull requests

4 participants