Skip to content

2.2.0 int parameter type definition in flask endpoint are not handled correctly #2473

@JanKhstll

Description

@JanKhstll

When defining the type of an url parameter in a flask endpoint the routing to this endpoint based on the type is not performed correctly anymore.

In the following setup also requests without the fitting parameter type are routed to the url:

Endpoint:
@api_blueprint.route("/enpoint_route/<int:id>", methods=['POST'])

Unittest:

response = client.post(
            '/enpoint_route/1123a',
            headers={'Accept': 'application/json',
                     "Content-Type": "application/json",
            "},
        )
self.assertEqual(response.status_code, 404)  # release 2.2.0: AssertionError: 200 != 404

Since release 2.2.0 when sending a parameter which is not an int the returned status code is 200 instead of 404.
In a very short testing the issue seems to be related to the int type. Testing with float worked as expected.

Environment:

  • Python version: 3.9
  • Werkzeug version: 2.2.0
  • Flask version: 2.1.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions