Skip to content

UnmarshallerError if specifying format with type: [foo, 'null'] #483

Description

@stephenfin

I'm still working on minimal reproducer to prove this out so apologies for the lack of a one in advance.

I've got a schema like this:

openapi: '3.1.0'# ...components:
schemas:
PatchList:
type: 'object'properties:
# ...pull_url:
title: 'Pull URL'type:
- 'string'
- 'null'format: 'uri'maxLength: 255# ...

If my server returns a response with pull_url set to null, then the call to openapi_core.validation.response.validators.ResponseValidator.validate fails with the following traceback:

Traceback (mostrecentcalllast):
File"/dev/patchwork/patchwork/tests/api/test_relation.py", line267, intest_remove_one_patch_from_relation_goodresp=self.client.patch(
File"/dev/patchwork/patchwork/tests/api/utils.py", line241, inpatchvalidator.validate_data(
File"/dev/patchwork/patchwork/tests/api/validator.py", line141, invalidate_dataresult.raise_for_errors()
File"/dev/openapi-core/openapi_core/validation/datatypes.py", line12, inraise_for_errorsraiseerrorFile"/dev/openapi-core/openapi_core/validation/response/validators.py", line245, invalidatedata=self._get_data(response, operation_response)
File"/dev/openapi-core/openapi_core/validation/response/validators.py", line88, in_get_datadata=self._unmarshal(schema, casted)
File"/dev/openapi-core/openapi_core/validation/validators.py", line76, in_unmarshalreturnunmarshaller(value)
File"/dev/openapi-core/openapi_core/unmarshalling/schemas/unmarshallers.py", line91, in__call__returnself.unmarshal(value)
File"/dev/openapi-core/openapi_core/unmarshalling/schemas/unmarshallers.py", line434, inunmarshalreturnunmarshaller.unmarshal(value)
File"/dev/openapi-core/openapi_core/unmarshalling/schemas/unmarshallers.py", line316, inunmarshalproperties=self.format(value)
File"/dev/openapi-core/openapi_core/unmarshalling/schemas/unmarshallers.py", line325, informatreturnself._unmarshal_properties(formatted, schema_only=schema_only)
File"/dev/openapi-core/openapi_core/unmarshalling/schemas/unmarshallers.py", line354, in_unmarshal_propertiesall_of_properties=self._clone(all_of_schema).format(
File"/dev/openapi-core/openapi_core/unmarshalling/schemas/unmarshallers.py", line325, informatreturnself._unmarshal_properties(formatted, schema_only=schema_only)
File"/dev/openapi-core/openapi_core/unmarshalling/schemas/unmarshallers.py", line373, in_unmarshal_propertiesproperties[prop_name] =self.unmarshallers_factory.create(
File"/dev/openapi-core/openapi_core/unmarshalling/schemas/unmarshallers.py", line91, in__call__returnself.unmarshal(value)
File"/dev/openapi-core/openapi_core/unmarshalling/schemas/unmarshallers.py", line433, inunmarshalunmarshaller=self._get_best_unmarshaller(value)
File"/dev/openapi-core/openapi_core/unmarshalling/schemas/unmarshallers.py", line430, in_get_best_unmarshallerraiseUnmarshallerError("Unmarshaller not found for type(s)")
openapi_core.unmarshalling.schemas.exceptions.UnmarshallerError: Unmarshallernotfoundfortype(s)

If I comment out format, things work as expected. I suspect it's attempting to apply a formatter for the null values. As far as I can tell, this should work though.

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