Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialization failure in service contract (webapi/AMQP and maybe more) #139

Open
thomas-kl1 opened this issue Oct 30, 2024 · 1 comment
Open

Comments

@thomas-kl1
Copy link

thomas-kl1 commented Oct 30, 2024

Error you will face:

"Sources" is not supported. Correct the field name and try again.

It's because if you pass to \Magento\Framework\Webapi\ServiceInputProcessor::convertValue the result of \Magento\Sales\Api\OrderRepositoryInterface::get (or getList), the Order object is badly formatted because of this plugin: \Ampersand\DisableStockReservation\Plugin\Model\OrderRepositoryPlugin. It seems that for some reason, the sourceCode is not serialized when Magento tries to rebuild the Sources extension attribute of the order (Magento\InventorySourceSelectionApi\Api\Data\SourceSelectionItemInterface).

Anyway I don't see any usage of this extension attribute in the code (Sources) so I guess it's safe to remove it and the plugin?

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
    <extension_attributes for="Magento\Sales\Api\Data\OrderInterface">
        <attribute code="sources" type="Magento\InventorySourceSelectionApi\Api\Data\SourceSelectionItemInterface[]" />
    </extension_attributes>
</config>
@thomas-kl1
Copy link
Author

thomas-kl1 commented Oct 31, 2024

My temporary fix is to unset the sources:
$order->getExtensionAttributes()?->setSources([]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant