Rest API GET /V1/products/attribute-sets/:id/attributes gives 500 server internal error.
Steps to reproduce
- Install Magento from
developbranch. - Create multiple attribute-sets with a lot of attributes assigned to them
- Make a GET call on /V1/products/attribute-sets/sets/list to get the list of all attribute-sets and their IDs.
- Make subsequent GET calls on /V1/products/attribute-sets/:ID/attributes for all attribute-sets.
Expected result
- It should return proper response for all the GET calls on /V1/products/attribute-sets/:ID/attributes
Actual result
- It gives proper response for some of the attribute-set IDs:
- It gives 500 response code and following error for some attribute-set IDs :
{ "messages": { "error": [ { "code": 500, "message": "Server internal error. See details in report api/501949553088" } ] } }
Actual calls and responses
- /V1/products/attribute-sets/sets/list?searchCriteria[filter_groups][2][filters][0][field]=created_at&searchCriteria[filter_groups][2][filters][0][value]=2015-05-02T18:30:00.000Z&searchCriteria[filter_groups][2][filters][0][conditionType]=gt
Response :
{ "items": [ { "attribute_set_id": 4, "attribute_set_name": "Default", "sort_order": 1, "entity_type_id": 4 }, { "attribute_set_id": 9, "attribute_set_name": "Helmet", "sort_order": 0, "entity_type_id": 4 }, { "attribute_set_id": 10, "attribute_set_name": "Ulti attributes", "sort_order": 0, "entity_type_id": 4 }, { "attribute_set_id": 11, "attribute_set_name": "Clothes - T shirts", "sort_order": 0, "entity_type_id": 4 } ], "search_criteria": { "filter_groups": [ { "filters": [ { "field": "entity_type_code", "value": "catalog_product", "condition_type": "eq" } ] } ] }, "total_count": 4 }
- /V1/products/attribute-sets/4/attributes
Response : 200 OK
[ { "attribute_id": 73, "attribute_code": "short_description", "frontend_input": "textarea", "entity_type_id": "4", "is_required": false, "options": [], "is_user_defined": false, "default_frontend_label": "Short Description", "frontend_labels": null, "backend_type": "text", "is_unique": "0", "validation_rules": [] },... ]
- /V1/products/attribute-sets/9/attributes
{ "messages": { "error": [ { "code": 500, "message": "Server internal error. See details in report api/501949553088" } ] } }
Hi @karanbhomiagit
Could you also share the content of 501949553088 report?
Thanks, Kateryna.
@katmoon : Following are the contents of 501949553088 report : "Fatal Error: 'Class '' not found' in '/var/www/mgdevcommunity/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php' on line 97"
@katmoon , this bug is one of the early stage blockers for Magento2 item integration we are trying to develop. Would you please update us about fix?
@katmoon : Do you have any update on error ?
Hi @karanbhomiagit , @ruby10 , @srinivasanithin ,
I cannot reproduce the issue with sample data. What is the difference between attribute sets that produce the error and other attribute sets?
Thanks, Kateryna.
@katmoon
In My case my failing attribute set was having two global attributes with dropdown field while other attribute set was not having that two global attribute dropdown attributes as part of it.
I created new attribute set and added one of the dropdown attribute to this new set. It was color with 8 values it was global and every other property is set to false.
I created this color attribute while creating a configurable item using add attribute option on product page. I am not sure at this point it why this attribute is causing issue for me. But when i add other similar attribute size, I am able to get the details. I view the error log for this 500 error it was same.
- Is there any way i can remove that color attribute from attribute set?
- how can i help you in reproducing this issue?
I have followed your structure of request i.e magento-host/V1/products/attribute-sets/sets/list
The response we are getting is
{ "message": "%fieldName is a required field.", "parameters": { "fieldName": "searchCriteria" } }
Can you please help me regarding this
@katmoon , please do provide update on it if there is any
@GiriManas You will need to provide a searchCriteria field as part url parameter then it will be accepting it.
May be try this magento-host/V1/products/attribute-sets/sets/list?searchCriteria[pageSize]=20 as url and you will find the response.
@katmoon : were you able to reproduce the issue? need any more information from me?
@srinivasanithin
Sorry that it took me too long to reply. We were very busy with testing to prepare release 2.1.
Is there any way i can remove that color attribute from attribute set?
Yes, you can remove any attribute by drag-n-drop back to Unassigned attributes. If it does not work, try to move it up and down over the list until you see a horizontal line.
I've created a new attribute while creating a configurable product, but cannot reproduce the issue. Are there any [reproducible steps](Please log a different issue for your problem https://github.com/magento/magento2/wiki/Issue-reporting-guidelines) or it happens only for 1 attribute? What happens when you remove 'color' attribute from the attribute set? Does the error persist?
According to contributor guide, tickets without response for two weeks should be closed. Please feel free to reopen if it's needed.
Error still here in 2019 with Magento2.0. Any clue?
After few investigations, I found a workaround, creating a custom module. etc/di.xml:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Eav\Model\AttributeManagement" type="My\Module\Model\AttributeManagement" />
</config>
Model/AttributeManagement.php
<?php
namespace My\Module\Model;
use Magento\Framework\Exception\NoSuchEntityException;
class AttributeManagement extends \Magento\Eav\Model\AttributeManagement
{
/**
* {@inheritdoc}
*/
public function getAttributes($entityType, $attributeSetId)
{
/** @var \Magento\Eav\Api\Data\AttributeSetInterface $attributeSet */
$attributeSet = $this->setRepository->get($attributeSetId);
$requiredEntityTypeId = $this->eavConfig->getEntityType($entityType)->getId();
if (!$attributeSet->getAttributeSetId() || $attributeSet->getEntityTypeId() != $requiredEntityTypeId) {
throw NoSuchEntityException::singleField('attributeSetId', $attributeSetId);
}
$attributeCollection = $this->attributeCollection
->setAttributeSetFilter($attributeSet->getAttributeSetId())
->load();
//This following method throws an exception because data are an array of empty objects
//return $attributeCollection->getItems();
//So I manually build the result, no matter if the format is good, at least it works
$result=[];
foreach($attributeCollection as $item) {
$result[]=$item->getData();
}
return $result;
}
}
In case the Magento team wants to fix that (let's dream), here is the content of the collection's _items property generated after the load():
{"162":{},"69":{},"76":{},"144":{},"93":{},"96":{},"116":{},"143":{},"161":{},"165":{},"252":{},"65":{},"70":{},"77":{},"79":{},"94":{},"97":{},"159":{},"166":{},"253":{},"66":{},"71":{},"78":{},"80":{},"98":{},"153":{},"167":{},"254":{},"67":{},"72":{},"81":{},"99":{},"160":{},"168":{},"255":{},"68":{},"73":{},"82":{},"100":{},"157":{},"256":{},"83":{},"151":{},"84":{},"88":{},"102":{},"156":{},"92":{},"74":{},"155":{},"258":{},"86":{},"112":{},"152":{},"259":{},"87":{},"113":{},"154":{},"260":{},"89":{},"115":{},"158":{},"509":{},"510":{},"511":{},"512":{},"513":{},"514":{},"515":{},"516":{},"517":{},"518":{},"91":{},"90":{},"120":{},"164":{},"95":{},"261":{},"101":{},"110":{},"262":{},"103":{},"163":{},"104":{},"105":{},"106":{},"107":{},"108":{},"109":{},"117":{},"118":{},"119":{},"121":{},"122":{},"123":{},"124":{},"125":{},"501":{},"502":{},"503":{},"505":{},"506":{},"507":{},"508":{},"504":{}}