Skip to content

Parameters are no longer validated according to standard type annotations in v4.0.0 #730

Description

@ryu1

Description

I recently upgraded flask-jsonrpc in my application to v4.0.0.

It appears that runtime validation based on standard Python type annotations is no longer performed starting from v4.0.0.

The same code behaves differently depending on the version:

v3.0.1: works as expected

v4.0.0: parameters are not validated

In the following example, standard type annotations such as str and Literal[0, 1] are specified.
However, in v4.0.0, invalid values are accepted and the method is executed.

@sample.method("sample.create_engineer")
@permission_required(has_permission=has_full_access)
def create_engineer(
    engineer_name: str,
    engineer_flg: Literal[0, 1],
):
    ...

Runtime: python v3.12.10

Observed behavior (v4.0.0)

Passing a value other than 0 or 1 (e.g. 99) to engineer_flg does not result in an error

Passing None to engineer_name does not result in an error

In all cases, the method is executed and HTTP 400 is not returned

Behavior in v3.0.1

In all of the above cases, HTTP 400 is returned and the method is not executed

Expected

As in v3.0.1, parameters should be validated based on standard type annotations

When parameters are invalid, HTTP status code 400 should be returned

The method should not be executed

Actual

In v4.0.0, the method is executed even when invalid parameter values are provided

HTTP 400 is not returned

Question

This behavior changed between v3.0.1 and v4.0.0.

In v3.0.1, parameters were validated based on standard type annotations, and invalid values resulted in HTTP 400.

In v4.0.0, the same invalid values are accepted and the method is executed.

Is this change an intentional specification change, or is it an unintended regression?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions