Problem/Motivation
When setting the term name as unique target, Feeds fails to restrict to search for an existing entity within the same vocabulary.
This can cause the following error:
InvalidArgumentException: Field feeds_item is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField()
Proposed resolution
When looking for an entity with the same name, restrict the search to entities within the same bundle (if the entity type in question supports bundles).
Original report by ksc
Two Problems: Server Error 500 - Field feeds_item is unknown / partial import
PHP: 5.6.33 (XAMPP Windows)
Drupal: 8.5.3
Feeds: 8.x-3.0-alpha1
Tamper: 8.x-1.x-dev updated 25 May 2018
Feeds Tamper: 8.x-2.x-dev updated 25 May 2018
Fetcher: Upload
Parser: CSV
Processor: Term (Taxonomy)
Processor settings: Update excisting ...
Fields:
- Term (set as unique)
- Plain Text
- Taxonomy Reference Field (Tamper: Break up sequenced data into an array)
- Taxonomy Reference Field (Tamper: Break up sequenced data into an array)
- Description
I have 611 records in cvs to import.
With the first import 497 records got imported, no error messages. No idea why only 497 - I checked the CSV with notepad++ but nothing special in lines 497 - 499, seem to be ok.
With a second try to import the csv file the follwoing message shows up:
"Ein AJAX-HTTP-Fehler ist aufgetreten. (an error occured)
HTTP-Rückgabe-Code: 500
Im Folgenden finden Sie Debugging-Informationen.
Pfad: /.../batch?id=134&op=do_nojs&op=do
Statustext: 500 Service unavailable (with message)
Antworttext: ..."
The drupal error protocol lists the following error:
"InvalidArgumentException: Field feeds_item is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 580 in C:\xampp\htdocs\...\core\lib\Drupal\Core\Entity\ContentEntityBase.php)."
I have around one thousand records more to import.
Thanks for your support! Thanks for provide this module!
Comments
Comment #2
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedIt looks like that you have accidentally removed the feeds_item field on your vocabulary. Resave the feed type and try again.
I'm considering in making the feeds_item field a base field on the entity so that you can no longer accidentally remove it and break your import. I've experimented with that idea in #2799225-14: The "hidden" plugin does not exist: Drupal\Component\Plugin\Exception\PluginNotFoundException:.
Comment #3
ksc CreditAttribution: ksc commentedMhm, the feeds_item field is still in the vocabulary - at least it shows up there.
When I try to edit it I get an error:
Location: .../admin/structure/taxonomy/manage/tx_indiref/overview/fields/taxonomy_term.tx_indiref.feeds_item
Message: Drupal\Component\Plugin\Exception\PluginNotFoundException: The "hidden" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 in ...\core\lib\Drupal\Component\Plugin\Discovery\DiscoveryTrait.php).
The curious thing is, that the first import went relatively well - 497 records of 611. (Why only 497?)
And the error (title of this issue) came when I tried to import again. Between two imports I didn´t touch the fields in the vocabulary, I just changed the filename of the csv-file for import.
Comment #4
ksc CreditAttribution: ksc commentedI´ll uninstall feeds (feeds tamper + tamper) and install it again and try to reproduce the problem - I started with a feeds dev version from some month ago.
I´ll let you know what happens.
By the way: feeds module can only be uninstalled when deleting everything backwards: the feeds, the tamper definitions, the assingments, and the feeds-types. Otherwise it can´t be uninstalled because of excisting fields.
Comment #5
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedYes, it's quite a hassle to uninstall Feeds. It could probably be made a bit easier if the feeds_item field was a base field. But do indeed individual tamper definitions need to be removed first too? I would think it would be enough to just delete the feed types and then the tamper plugin instances would be deleted with them. This is because the tamper plugin instances are saved on the feed type itself.
Note: on the uninstall modules page there is a link to delete all feed entities.
Comment #6
ksc CreditAttribution: ksc commentedSo after uninstall, new install etc what happened is:
Created 1 items
Updated 496 items
(total 611 records)
and it ended with the same error:
Server Error 500
protocol:
InvalidArgumentException: Field feeds_item is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (Zeile 580 in C:\xampp\htdocs\medikartei-8-1\core\lib\Drupal\Core\Entity\ContentEntityBase.php).
Comment #7
ksc CreditAttribution: ksc commentedUninstalling feeds - your question about uninstall tamper items:
I´m not sure about this point. At least I had to delete the assignments within the feeds types and then delete the types itself.
The link to delete all feed entities shows up now - it was not here before.
Comment #8
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedHm, I think this is caused by the following issue: #2820548: Fatal error when triggering Feeds via cron .
If you deleted a feed type for which an import is still in progress, the import task remains in the queue. And when the import task runs, it cannot find the feed type, fails with an error similar as above and holds up other import tasks in the queue. Can you try the patch from #2820548-15: Fatal error when triggering Feeds via cron and see if that fixes your issue? The error reported in the other issue is different though (
Call to a member function hasTranslation() on null
), so maybe it doesn't help.Comment #9
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedOr did you perform an import using the UI?
Comment #10
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedWait, you did. Else you would not have gotten an AJAX error.
Can you try to reproduce the issue on a fresh install of Drupal? To rule out possible module conflicts?
Comment #11
ksc CreditAttribution: ksc commentedYes, I used the UI.
OK, I´ll try it with a fresh installation. Will take a while - I don´t have and know the smart developer tools. :-)
Comment #12
ksc CreditAttribution: ksc commentedSo: with a fresh installation 8.5.3 (I have chosen German language):
Items imported: 497
(all correct)
Same error: Ajax Server Error 500
Comment #13
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedThat's interesting. Does the same error occur if you only import lines 497 - 499 from the CSV file?
This bug looks like one that would be hard to reproduce without knowing how your configuration exactly looks like and what content you are trying to import. If you can share your configuration and a file that triggers the error, that would be helpful. Sharing configuration can be done with a feature module. Make sure that the feature module contains the following:
Tamper plugin instances are stored on the feed type in D8.
Comment #14
ksc CreditAttribution: ksc commentedAha.
I imported lines 497 - 501 from the CSV file.
One record/item got imported - then Error 500.
I checked the csv-file with a hexeditor but can´t find anything unusual - just German Umlaute like ä,ö etc and + () which occur also in previous records/items.
Attached the configuration and the csv-file. Hope, I dexported the right configurations.
I´m curious what you´ll find out. :-)
Comment #15
MegaChriz CreditAttribution: MegaChriz as a volunteer commented@ksc
I took me a few days before I could find time to look at this. I've found the cause of the issue! The issue is as follows:
Conclusion: there is a bug in Feeds: when setting the term name as unique target, Feeds fails to restrict to search for an existing entity within the same vocabulary.
Possible workaround: Map 'Suchbegriff' also to 'Feeds item: Item GUID' and use that as unique target instead.
Comment #16
ksc CreditAttribution: ksc commentedOK, thanks a lot :-)
This was a tricky one. So I know, what kind o f data I have to avoid at the moment.
Just a remark to the suggested workaround: when using feeds_item: Item GUID as unique, the vocabulary or content type needs to be empty, otherwise one could get double entries.
Comment #17
MegaChriz CreditAttribution: MegaChriz as a volunteer commented@ksc
You are right that if you add mapping to 'Feeds item: Item GUID' and set that as unique right away, the vocabulary needs to be empty as it else would lead to duplicates.
You could however add the mapping to 'Feeds item: Item GUID', keep 'Term name' as the unique target and import all records again that could be imported without errors. Then all imported terms will have a value for 'Feeds item: Item GUID'. You can then switch over to use 'Feeds item: Item GUID' as unique target and duplicates will be avoided.
Comment #18
Omar AlahmedActually, I have the same problem with two node importers, both of them has the same GUID integer value for different two fields and different bundles.
This is because the following line of code in existingEntityId() returns a conflict GUID because it doesn't restrict the query to the bundle:
$entity_id = $plugin->getUniqueValue($feed, $mapping['target'], $key, $item->get($mapping['map'][$key]));
And sometimes it returns a warning 'Field field_name_goes_here is unknown' when it finds a GUID of the other content type and not match the importer bundle or content type.
The following patch will add an extra condition by the bundle key and bundle value and it works in my case.
Comment #19
Omar AlahmedComment #21
chadrossouw CreditAttribution: chadrossouw commentedI had a similar problem, when trying to update nodes using their title as a unique identifier. The patch worked to resolve my issue. Commenting here to say thank you!
Comment #22
carolpettirossi CreditAttribution: carolpettirossi at Prosple commentedI was facing the same issue when importing taxonomies. The feed type has the "Update existing taxonomy terms" flagged and "Name" as Unique lookup.
I've applied the patch provided by Omar on #18 solved my issue.
Thanks,
Carol
Comment #23
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedI think that the reason that the test failed is because not every entity type has a bundle key.
New patch, also with a test. Tests only patch should fail.
Comment #26
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedTests are passing now and the test only patch demonstrates the issue.
Committed #23.
Comment #27
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedCrediting the reviewers.