Skip to content

symfony/serializer version 7.0.7 now throws NotNormalizableValueException  #54784

@verfriemelt-dot-org

Description

@verfriemelt-dot-org

Symfony version(s) affected

7.0.7

Description

i inherited the following code, and now i am unsure wether this is a bug in the last patch-release or a bug in my code. up until version 7.0.6 it worked just fine so far.

How to reproduce

<?xml version="1.0" encoding="UTF-8"?>
<Trias>
    <ServiceDelivery>
        <DeliveryPayload>
            <TripResponse>
                <foo />
                <foo />
            </TripResponse>
        </DeliveryPayload>
    </ServiceDelivery>
</Trias>

with the following DTOs

final class Trias
{
    private ?ServiceDeliveryStructure $serviceDelivery = null;

    /**
     * @return ServiceDeliveryStructure
     */
    public function getServiceDelivery()
    {
        return $this->serviceDelivery;
    }

    public function setServiceDelivery(ServiceDeliveryStructure $serviceDelivery): void
    {
        $this->serviceDelivery = $serviceDelivery;
    }
}
final class ServiceDeliveryStructure
{
    private ?DeliveryPayloadStructure $deliveryPayload = null;

    /**
     * @return DeliveryPayloadStructure
     */
    public function getDeliveryPayload()
    {
        return $this->deliveryPayload;
    }

    public function setDeliveryPayload(DeliveryPayloadStructure $deliveryPayload): void
    {
        $this->deliveryPayload = $deliveryPayload;
    }
}
final class DeliveryPayloadStructure
{
    private ?TripResponse $tripResponse = null;

    /**
     * @return TripResponse
     */
    public function getTripResponse()
    {
        return $this->tripResponse;
    }

    public function setTripResponse(TripResponse $tripResponse): void
    {
        $this->tripResponse = $tripResponse;
    }
}

starting with version 7.0.7 i'll get the following error:

Symfony\Component\Serializer\Exception\NotNormalizableValueException: The type of the "tripResponse" attribute for class "EosUptrade\FIS\TRIAS\Dto\DeliveryPayloadStructure" must be one of "EosUptrade\FIS\TRIAS\Dto\TripResponse" ("array" given).

when calling

$serializer->deserialize($content, Trias::class, XmlEncoder::FORMAT);

with the following service configuration:

    $services->set('trias.name_converter', UppercaseFirstLetterNameConverter::class);
    $services->set('trias.property_type_extractor', PhpDocExtractor::class);

    $services
        ->set('trias.get_set_method_normalizer', GetSetMethodNormalizer::class)
        ->args([
            null,
            service('trias.name_converter'),
            service('trias.property_type_extractor'),
        ]);

    $services->set('trias.array_denormalizer', ArrayDenormalizer::class);
    $services->set('trias.xml_encoder', XmlEncoder::class);

    $services
        ->set('trias.serializer', Serializer::class)
        ->public()
        ->args([
            [
                service('trias.get_set_method_normalizer'),
                service('trias.array_denormalizer'),
            ],
            [service('trias.xml_encoder')],
        ]);

Possible Solution

No response

Additional Context

No response

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