magento2
magento2 copied to clipboard
OptionValueProvider class get() method contains an incorrect query value
Preconditions and environment
- Magento version: 2.4.3
Steps to reproduce
- From the main directory of a project, navigate to: vendor/magento/module-eav/model/resourcemodel/entity/attribute/OptionValueProvider
- Scroll down to the public function get() method.
The description of this method reads: "Get EAV attribute option value by option id", which makes sense as this is a value easily gained from a Product object. However, the rest of the query that is being built mentions '$valueId' and a where-condition that is aimed at the column named 'value_id'. This colum does not exists in the 'eav_attribute_option_value' table, leading to an error when used.
Expected result
This method should return an attribute option value based on the given option_id.
Actual result
This method returns only an error, as the 'value_id' column is not present.
Additional information
This issue can be fixed by changing the the first parameter name to '$optionId', and changing the first parameter of the ->where method to 'option_id'. Code as example:
private function get(int $optionId): ?string { $select = $this->connection->select() ->from($this->connection->getTableName('eav_attribute_option_value'), 'value') ->where('option_id = ?', $optionId);
$result = $this->connection->fetchOne($select);
if ($result) {
return $result;
}
return null;
}
Kind regards, Lukas de Ruiter Youwe B.V.
Release note
No response
Triage and priority
- [ ] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- [ ] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- [ ] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- [X] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- [ ] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Hi @LukasDeRuiter. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:
- Summary of the issue
- Information on your environment
- Steps to reproduce
- Expected and actual results
Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:
@magento give me 2.4-develop instance
- upcoming 2.4.x release
For more details, review the Magento Contributor Assistant documentation.
Add a comment to assign the issue: @magento I am working on this
To learn more about issue processing workflow, refer to the Code Contributions.
- Join Magento Community Engineering Slack and ask your questions in #github channel.
:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
:clock10: You can find the schedule on the Magento Community Calendar page.
:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.
:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel
Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
-
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
Details
If the issue has a valid description, the labelIssue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until labelIssue: Format is valid
appears. -
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add
Issue: Clear Description
label to the issue by yourself. -
[ ] 3. Add
Component: XXXXX
label(s) to the ticket, indicating the components it may be related to. -
[ ] 4. Verify that the issue is reproducible on
2.4-develop
branchDetails
- Add the comment@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.4-develop
branch, please, add the labelReproduced on 2.4.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here! -
[ ] 5. Add label
Issue: Confirmed
once verification is complete. -
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hello @LukasDeRuiter,
Thanks for the report and collaboration!
We have tried to reproduce the issue in Magento 2.4-develop branch but were unable to do so. We can see the value_id
column in eav_attribute_option_value
table. Please refer the below screenshot for reference:

Let us know in case we have missed anything.
Thanks
Dear @LukasDeRuiter,
We have noticed that this issue has not been updated for a period of 14 Days. Hence we assume that this issue is fixed now, so we are closing it. Please raise a fresh ticket or reopen this ticket if you need more assistance on this.
Regards
Hi,
I can confirm @LukasDeRuiter's report. While there are both columns, the docblock explicitely states
Get EAV attribute option value by option id
It lies!
Problem
I struggled to understand why this class was introduced in the core and commits aren't helpufl in that sense.
Moreover, there is no usage of this class in Magento OpenSource (on 2.4-develop
):
$ git rev-parse --short HEAD
26057964cdb
$ rg -i "OptionValueProvider"
app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/OptionValueProvider.php
17:class OptionValueProvider
It however is used in Adobe Commerce, by the RMA GraphQL module:
$ rg -i "OptionValueProvider" vendor/magento
vendor/magento/module-eav/Model/ResourceModel/Entity/Attribute/OptionValueProvider.php
18:class OptionValueProvider
vendor/magento/module-rma-graph-ql/Model/Rma/Item/Builder.php
14:use Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionValueProvider;
50: * @var OptionValueProvider
52: private $optionValueProvider;
59: * @param OptionValueProvider $optionValueProvider
66: OptionValueProvider $optionValueProvider
72: $this->optionValueProvider = $optionValueProvider;
156: if ($this->optionValueProvider->get((int)$attributeValue)) {
vendor/magento/module-rma-graph-ql/Model/Formatter/CustomAttribute.php
12:use Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionValueProvider;
32: * @var OptionValueProvider
34: private $optionValueProvider;
39: * @param OptionValueProvider $optionValueProvider
44: OptionValueProvider $optionValueProvider
48: $this->optionValueProvider = $optionValueProvider;
61: $value = $this->optionValueProvider->get((int)$value);
As a consequence, the RMA GraphQL module doesn't work.
To reproduce
Install Adobe Commerce with sample data.
Remove the following line in the DB (DELETE FROM eav_attribute_option_value WHERE
eav_attribute_option_value.
value_id = 221
):
Try to create a return using the RequestReturnMutation
GraphQL mutation with "Reason: Wrong Color".
What happens
GraphQL returns an error due to Magento\RmaGraphQl\Model\Rma\Item::Builder
calling the method with an option_id value (if ($this->optionValueProvider->get((int)$attributeValue)) {
).
The error is:
{
"operationName": "RequestReturnMutation",
"variables": {
"input": {
"contact_email": "[email protected]",
"order_uid": "NA==",
"items": [
{
"order_item_uid": "NQ==",
"quantity_to_return": 1,
"selected_custom_attributes": [
{
"attribute_code": "resolution",
"value": "MjE1"
},
{
"attribute_code": "condition",
"value": "MjE5"
},
{
"attribute_code": "reason",
"value": "MjIx"
}
]
}
]
}
},
"data": [
{
"message": "Value of reason is incorrect",
"extensions": {
"category": "graphql-input"
},
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"requestReturn"
]
}
]
}
Expected
It should accept the return request and save it.
Next
I'll submit a PR to change this value, and see if no regression is detected by the Magento OpenSource test suite. Could you please reopen this issue?
Hello @real34,
Thanks for the contribution!
We are reopening this issue for further processing.
We have a query here, in your comment you have mentioned the mutation RequestReturnMutation
but instead, we have found this mutation requestReturn
here in the document. Are you talking about the same?
And also can you please tell us your mutation query?
Thanks
Hi @engcom-Hotel, Thanks for reopening.
It indeed is requestReturn
.
Here is the code of our mutation:
mutation RequestReturnMutation($input: RequestReturnInput!) {
requestReturn(input: $input) {
return {
order {
id
}
}
}
}
Hello @real34,
Thanks for the response!
Based on your comment, we have tried to reproduce the issue in Magento 2.4-develop branch. And the issue is reproducible for us. It seems that there is a mismatch in comment vs functionality. In the comment, it is written that the getting EAV attribute option value by option id
but actually it is getting by value_id
in the get
method of app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/OptionValueProvider.php
.
Hence confirming the issue and updating the description.
Thanks
:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-6680 is successfully created for this GitHub issue.
:white_check_mark: Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
Hi @LukasDeRuiter , Development team is currently working on this issue. Thank you.
Hello,
As I can see this issue got fixed in the scope of the internal Jira ticket AC-6680 by the internal team Related commits:https://github.com/search?q=repo%3Amagento%2Fmagento2+AC-6680&type=commits
Based on the Jira ticket, the target version is 2.4.7-beta1.
Thanks