Skip to content

No Payload Validation #2392

@arb

Description

@arb

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.

Metadata

Metadata

Assignees

Labels

bugBug or defect

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions