python-openapi / openapi-core

Openapi-core is a Python library that adds client-side and server-side support for the OpenAPI v3.0 and OpenAPI v3.1 specification.
BSD 3-Clause "New" or "Revised" License
287 stars 131 forks source link

[Bug]: validation shouldn't fail when values contain array with null #822

Open wosc opened 3 months ago

wosc commented 3 months ago

Actual Behavior

This issue is somewhat similar to #551, only with a list in the input ({'names': [None]} instead of {'name': None}), and this time RecursionExceeded is raised instead of UnmarshallerError.

Expected Behavior

Should not raise an exception.

Steps to Reproduce

Here's a test case, modelled after the one in #555 (that fixed #551). This also shows that somehow the issue is limited to the 3.0 code path, because it works just fine with 3.1

    @pytest.mark.parametrize('factory', [
        oas30_write_schema_unmarshallers_factory,
        oas31_schema_unmarshallers_factory])
    def test_object_with_array_of_null(self, factory):
        schema = {}
        spec = SchemaPath.from_dict(schema)
        unmarshaller = factory.create(spec)
        result = unmarshaller.unmarshal({'foo': [None]})
        assert result == {'foo': [None]}

OpenAPI Core Version

0.19.0

OpenAPI Core Integration

pyramid-openapi3

Affected Area(s)

unmarshalling

References

No response

Anything else we need to know?

No response

Would you like to implement a fix?

No

hannu-oura commented 2 months ago

I was also able to replicate this issue with altering the test case here:

https://github.com/python-openapi/openapi-core/blob/master/tests/integration/unmarshalling/test_unmarshallers.py#L582

By adding another case ("array", [None])

Also ends up in RecursionError: maximum recursion depth exceeded in comparison