Skip to content

RequestParser.parse_args() returns stupid validation error #384

Closed
@ghost

Description

When I have something like

parser = reqparse.RequestParser()
parser.add_argument('caption', type=datetime, help='This is caption')  # Stupid example with datetime which is not supported
parser.parse_args()

then in case that parser.parse_args() returns validation error (abort(400)) and I get response like this:

{
    "message": "This is caption"
}

which obviously makes no sense because I don't know what happened.

If I have arg definition without help attribute like this:

parser.add_argument('caption', type=datetime)

I get

{
    "message": "an integer is required"
}

which is nice but I don't which field the message refers to.

Better approach would be something like:

{
    "message": "[caption] - an integer is required"
}

All that is needed is to change some lines in reqparse.Argument.handle_validation_error() which is responsible for message above:)

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions