Open figuernd opened 1 year ago
Given this response:
const testBuffer = Buffer.from('hello world', 'binary'); return h.response(csv_results).encoding('binary') .header('Content-Length', testBuffer.length) .type('application/octet-stream').code(200);
With this config:
response: { status: { 200: Joi.binary() }, },
Debug: internal, implementation, error Error: Cannot validate non-object response at exports.response (/node_modules/@hapi/hapi/lib/validation.js:179:20)
Success/no error.
Observing @hapi/lib/validation.js, the error appears to be that the the "binary" response schema is not being honored, with request.response.variety being set to "plain" when it should be "buffer".
@hapi/lib/validation.js
request.response.variety
if (!response.isBoom && request.response.variety !== 'plain') { throw Boom.badImplementation('Cannot validate non-object response'); }
My workaround has been to simply remove status validation from the config altogether.
Support plan
Context
What are you trying to achieve or the steps to reproduce?
Given this response:
With this config:
What was the result you got?
What result did you expect?
Success/no error.
Observing
@hapi/lib/validation.js
, the error appears to be that the the "binary" response schema is not being honored, withrequest.response.variety
being set to "plain" when it should be "buffer".