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

No Payload Validation #2392

Closed
arb opened this issue Feb 5, 2015 · 1 comment
Closed

No Payload Validation #2392

arb opened this issue Feb 5, 2015 · 1 comment
Assignees
Labels
Milestone

Comments

@arb
Copy link
Contributor

@arb arb commented Feb 5, 2015

Unless I'm misreading the docs, the code below should validate that 204 status code responses should not have a payload.

server.route({
    method: 'GET',
    path: '/',
    config: {
        response: {
            status: {
                204: false
            }
        },
        handler: function (request, reply) { reply().code(204); }
    }
});

However, if you make a request to "/" you get an error

Debug: internal, implementation, error 
    Error: value must be an object

Is this intentional or a bug? Tracing the code, it looks like a Joi validation schema is created https://github.com/hapijs/hapi/blob/master/lib/route.js#L101-L106 with the value of false which turns into an empty object and then that makes 204 responses required to be an object, instead of nothing.

@Marsup
Copy link
Contributor

@Marsup Marsup commented Feb 5, 2015

Probably because of

return (rule === false ? Joi.object({})
.

@hueniverse hueniverse added the bug label Feb 7, 2015
@hueniverse hueniverse self-assigned this Feb 9, 2015
@hueniverse hueniverse closed this in b3cce44 Feb 9, 2015
@hueniverse hueniverse added this to the 8.2.0 milestone Feb 9, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jan 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants