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

500 when creating new product after adding attribute via API and assigning to attribute set via UI #26827

Closed
vincentteyssier opened this issue Feb 12, 2020 · 10 comments
Assignees
Labels
Component: Eav Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reported on 2.3.4 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@vincentteyssier
Copy link

vincentteyssier commented Feb 12, 2020

Preconditions (*)

Magento 2.3.4
PHP 7.3

Steps to reproduce (*)

  1. Create new attribute using API
// End point: POST "/rest/default/V1/products/attributes";

// prepare the payload
$data = array(
  "attribute" => array(
    "is_wysiwyg_enabled" => false,
    "is_html_allowed_on_front" => true,
    "used_for_sort_by" => true,
    "is_filterable" => true,
    "is_filterable_in_search" => true,
    "is_used_in_grid" => true,
    "is_visible_in_grid" => true,
    "is_filterable_in_grid" => true,
    "position" => 0,
    "is_searchable" => true,
    "is_visible_in_advanced_search" => true,
    "is_comparable" => true,
    "is_used_for_promo_rules" => false,
    "is_visible_on_front" => true,
    "used_in_product_listing" => true,
    "is_visible" => true,
    "attribute_code" => "test_api",
    "frontend_input" => "swatch_text",
    "entity_type_id" => "4",
    "is_required" => true,
    "is_user_defined" => true,
    "default_frontend_label" => "test_api2",
    "frontend_labels" => [
      array(
        "store_id" => 0,
        "label" => "test_api3"
      )
    ],
    "backend_type" => "int",
    "is_unique" => false,
    "is_required" => false
  )
);

$payload = json_encode($data);

// make the call
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json' , $auth ));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch);
  1. Log in to Admin panel, go to Stores/Attributes/Attributes Set
  2. Add the newly created attrbute to the default attribute set
  3. Go to product page and click ADD PRODUCT

Expected result (*)

Product creation page should display normally

Actual result (*)

Error 500
Nginx logs below:

2020/02/12 04:45:19 [error] 1023#1023: *46116 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught TypeError: Argument 2 passed to Magento\Framework\View\Element\UiComponentFactory::argumentsResolver() must be of the type array, null given, called in /opt/magento/public_html/vendor/magento/framework/View/Element/UiComponentFactory.php on line 222 and defined in /opt/magento/public_html/vendor/magento/framework/View/Element/UiComponentFactory.php:174
Stack trace:
#0 /www/vendor/magento/framework/View/Element/UiComponentFactory.php(222): Magento\Framework\View\Element\UiComponentFactory->argumentsResolver('test_api', NULL)
#1 /www/vendor/magento/module-ui/Component/Form/Field.php(85): Magento\Framework\View\Element\UiComponentFactory->create('test_api', 'swatch_text', Array)
#2 /www/vendor/magento/framework/View/Layout/Generator/UiComponent.php(164): Magento\Ui\Component\Form\Field->prepare()
#3 /www/vendor/magento/framework/View/Layout/Generator/UiComponent.php(161): Magento\Fr" while reading response header from upstream, client: 127.0.0.1, server: example.com, request: "GET /admin_xxx/catalog/product/new/set/4/type/simple/key/zzzzzzzzzzz/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.3-fpm-magento.sock:", host: "example.com", referrer: "https://example.com/admin_xxx/catalog/product/index/key/yyyyyyyyyy/"

@m2-assistant
Copy link

m2-assistant bot commented Feb 12, 2020

Hi @vincentteyssier. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

@vincentteyssier do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Feb 12, 2020
@vincentteyssier
Copy link
Author

Additional comment: if I go to the test attribute page and save it without modifying anything the 500 does not occur anymore

@vincentteyssier
Copy link
Author

vincentteyssier commented Feb 12, 2020

I digged a bit into the code and can see that what gives NULL in argumentsResolver('test_api', NULL) comes from $rawComponentData = $this->definitionData->get($name) and $name is 'swatch_text' as we can see in the create instruction.
This is the frontend_input parameter in the API call.
swatch_text is an allowed value so why does it return NULL ?

@vincentteyssier
Copy link
Author

Also notice the reindexer is failing, even when I set searchable fields to false:

Catalog Search indexer process unknown error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'e.test_api' in 'field list', query was: SELECT `e`.`entity_id`, `e`.`type_id`, `e`.`sku`, `e`.`test_api` FROM `catalog_product_entity` AS `e`
 INNER JOIN `catalog_product_website` AS `website` ON website.product_id = e.entity_id AND website.website_id = 1
 INNER JOIN `catalog_product_entity_int` AS `visibility_default` ON visibility_default.entity_id= e.entity_id AND visibility_default.attribute_id = '99' AND visibility_default.store_id = 0
 LEFT JOIN `catalog_product_entity_int` AS `visibility_store` ON visibility_store.entity_id= e.entity_id AND visibility_store.attribute_id = '99' AND visibility_store.store_id = '1'
 INNER JOIN `catalog_product_entity_int` AS `status_default` ON status_default.entity_id= e.entity_id AND status_default.attribute_id = '97' AND status_default.store_id = 0
 LEFT JOIN `catalog_product_entity_int` AS `status_store` ON status_store.entity_id= e.entity_id AND status_store.attribute_id = '97' AND status_store.store_id = '1' WHERE (IF(visibility_store.value_id > 0, visibility_store.value, visibility_default.value) IN (3, 2, 4)) AND (IF(status_store.value_id > 0, status_store.value, status_default.value) IN (1)) AND (e.entity_id > 0) AND (e.entity_id < 501) ORDER BY `e`.`entity_id` ASC
 LIMIT 500

@engcom-Delta engcom-Delta self-assigned this Feb 13, 2020
@m2-assistant
Copy link

m2-assistant bot commented Feb 13, 2020

Hi @engcom-Delta. 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: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: 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 branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced 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.

@engcom-Delta engcom-Delta added Component: Eav Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Feb 13, 2020
@ghost ghost unassigned engcom-Delta Feb 13, 2020
@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Feb 13, 2020
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @engcom-Delta
Thank you for verifying the issue. Based on the provided information internal tickets MC-31474 were created

Issue Available: @engcom-Delta, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@magento magento deleted a comment from m2-assistant bot Feb 14, 2020
@vincentle89
Copy link
Contributor

Hi guys,

This issue happens when we save a product attribute with "frontend_input" => "swatch_text" via API. Other front_input types like text,... haven't happened.
We need someone checkout logic of repository: function save(app/code/Magento/Catalog/Model/Product/Attribute/Repository.php).
@vincentteyssier After you create a product attribute via API, you can go to that product attribute in admin and save it again. This error will be resolved.
I think this issue will take a lot of time to resolve it.
Cheers,

@vincentteyssier
Copy link
Author

Hi and thanks for looking into this. The workaround is a bit tedious since I might have to do that for hu ndreds of products, but not much of a choice :)
I reported another issue with the attributes option API when attribute is swatch_text.... not sure this helps, but there seems to be a few issues related to swatch text.
Thanks a lot and good luck!

@sergiy-v sergiy-v self-assigned this Mar 5, 2020
@m2-assistant
Copy link

m2-assistant bot commented Mar 5, 2020

Hi @sergiy-v. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

  • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced 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!

  • 3. If the issue is not relevant or is not reproducible any more, feel free to close it.


@magento-engcom-team magento-engcom-team added the Fixed in 2.4.x The issue has been fixed in 2.4-develop branch label Mar 19, 2020
@magento-engcom-team
Copy link
Contributor

Hi @vincentteyssier. Thank you for your report.
The issue has been fixed in #27191 by @sergiy-v in 2.4-develop branch
Related commit(s):

The fix will be available with the upcoming 2.4.0 release.

@magento-engcom-team magento-engcom-team added the Reported on 2.3.4 Indicates original Magento version for the Issue report. label Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Eav Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reported on 2.3.4 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
None yet
Development

No branches or pull requests

5 participants