Skip to content

500 error caused by type conversion in schema #3

@jksdua

Description

@jksdua

Schema middleware doesnt check if value is truthy before trying to convert. Also doesnt do any guarding to throw a nice schema error instead of a 500.

SyntaxError: Unexpected token u\n    at Object.parse (native)\n    at Object.convertTo.object (/home/cute/Documents/scw/backend-2/node_modules/koa-framework/middleware/schema.js:23:17)\n    at convertOne (/home/cute/Documents/scw/backend-2/node_modules/koa-framework/middleware/schema.js:30:36)\n    at convertOne (/home/cute/Documents/scw/backend-2/node_modules/koa-framework/middleware/schema.js:35:19)\n    at convertStringToType (/home/cute/Documents/scw/backend-2/node_modules/koa-framework/middleware/schema.js:48:21)\n    at Object.<anonymous> (/home/cute/Documents/scw/backend-2/node_modules/koa-framework/middleware/schema.js:128:9)\n    at next (native)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions