-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Class as request type for message queue with camel-case properties in constructor not instantiated properly #39217
Comments
Hi @smartexcan. Thank you for your report.
Join Magento Community Engineering Slack and ask your questions in #github channel. |
Hi @engcom-Hotel. Thank you for working on this issue.
|
Hello @smartexcan, We request you to please provide more details on below:
Thanks |
Created a module to demonstrate the issue. See the included readme for steps to run, then check logs for class instantiation error. |
As a side note, the InventorySales module uses an almost identical process, but the fields in their request data class are single words, which don't get changed to snake-case. |
Hello @smartexcan, Thanks for the prompt action on this issue. We have tried to proceed with the steps mentioned in the
Thanks |
Yes that would be the error I was getting as well. As mentioned in the first post, the properties got converted from camel case to snake case when serialized, but aren't converted back to camel case during reconstruction, which results in no params being sent to the object constructor. Workarounds for it would be using single word property names, grouping them in a data property, or extending from AbstractSimpleObject or DataObject |
Thanks @smartexcan for the confirmation. We are confirming this issue for further processing. The community can also raise PRs to fix certain issues as part of the process. Therefore, I suggest creating a community PR to address this fix. Thanks |
✅ Jira issue https://jira.corp.adobe.com/browse/AC-13230 is successfully created for this GitHub issue. |
✅ Confirmed by @engcom-Hotel. Thank you for verifying the issue. |
Summary
Using a class for the message queue request type, and having the properties in the constructor using camel-case names, the object cannot be instantiated properly as the object data keys are converted to snake-case.
Tested/reporting on 2.4.6-p6, though i don't think it has changed in a while.
Examples
(Magento\Framework\MessageQueue\MessageEncoder calls the service input and output processors)
Magento\Framework\Webapi\ServiceOutputProcessor::convertValue
converts the class to the following:Then in
\Magento\Framework\Webapi\ServiceInputProcessor::getConstructorData
, the keys do not match since they were converted to snake-case, but they are expected in camel-case, so an empty array is passed to objectmanager to create the object, resulting in an error due to not passing any arguments to constructor.The only way I can currently get around this issue is having the class extend AbstractSimpleObject or DataObject and adding setters (or using the data constructor argument)
Proposed solution
No response
Release note
No response
Triage and priority
The text was updated successfully, but these errors were encountered: