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

Closed
twhitbeck opened this issue Oct 26, 2017 · 5 comments
Closed
Assignees
Milestone

Comments

@twhitbeck
Copy link

@twhitbeck 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

hapi/lib/response.js

Lines 82 to 87 in ec5eaca

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

What was the result you received?

null

What did you expect?

empty string

Context

  • node version: 8.8.0
  • hapi version: 16.6.2
  • os: Debian
@AdriVanHoudt
Copy link
Contributor

@AdriVanHoudt AdriVanHoudt commented Oct 27, 2017

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

@Marsup
Copy link
Contributor

@Marsup Marsup commented Oct 27, 2017

He assigned himself, unlikely.

@AdriVanHoudt
Copy link
Contributor

@AdriVanHoudt AdriVanHoudt commented Oct 27, 2017

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

@hueniverse
Copy link
Contributor

@hueniverse hueniverse commented Oct 27, 2017

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
@lock
Copy link

@lock 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.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants