I've created a CSV feed via Views Export that exports out data for a content type. I'm then using Feeds to import that onto another Drupal site.

Everything except the images are working, when I run import it's stating

Failed importing 2 RSS Item items.

The content failed to validate with the following errors:
Image (field_image): Image: this field cannot hold more than 1 values.
Please check your mappings.

The field in question on Site A has a single limited value of 1, and checking the CSV export it's only showing one value, the absolute url of the image on Site A.

I've attempted to use Feeds Tamper and use all the plugins I can think of to fix this, but due to my freshness to Feeds and Feeds Tamper I'm not sure if this is a bug or misconfig on my part. Everything else is importing as expected onto Site B.

Comments

Robhern135 created an issue. See original summary.

megachriz’s picture

Status: Active » Postponed (maintainer needs more info)

It sounds like a misconfiguration, but it can also be that your source provides two (or more) values for the image field. It could be an empty value + an actual image url.

Can you share how your source looks like?

megachriz’s picture

Oh wait, I see something that could be an important detail in your description:

Failed importing 2 RSS Item items.

checking the CSV export

Are you importing from a RSS feed or from a CSV file? On the feed type, did you select the right parser?

Robhern135’s picture

Re #3:
When I view the exported CSV its showing just the one value, the absolute url, without and white space or any other characters that I can find.

Also the RSS Item is the name of the content type, when I first started attempting this process I was working with an RSS feed but realised I needed more control over the data than RSS feed could provide. The content type name RSS Item is arbitrary.

Re #4:
I'm exporting a Data Export View from Site A as a CSV and using Feeds to import as CSV.

Here's my parser section of the feed config:

parser: csv
parser_configuration:
  delimiter: ','
  no_headers: false
  line_limit: 100
Robhern135’s picture

Re #3:
When I view the exported CSV its showing just the one value, the absolute url, without and white space or any other characters that I can find.

Also the RSS Item is the name of the content type, when I first started attempting this process I was working with an RSS feed but realised I needed more control over the data than RSS feed could provide. The content type name RSS Item is arbitrary.

Re #4:
I'm exporting a Data Export View from Site A as a CSV and using Feeds to import as CSV.

Here's my parser section of the feed config:

parser: csv
parser_configuration:
  delimiter: ','
  no_headers: false
  line_limit: 100
Robhern135’s picture

RE: #2

When I view the exported CSV file it's jsut showing the absolute path of the image in question, with no other characters or spaces to get a second items from.
RSS Item is just the name of the content type that I made to house the content, when I started I intended to use RSS but I realised I needed more control over the data and fields.

RE: #3
I'm exporting a CSV data export from Site A using Views Data Export and importing using Feeds to Site B.

I've selected CSV parser to match.

megachriz’s picture

In order to help you further, I will need to see an export of your configuration + a sample source file. It could be there's something strange in the CSV file that is causing this or that there's a misconfiguration.

Can you provide the following:

  • The source file you were trying to import (may also be a sample file, as long as that sample file can demonstrate the problem).
  • An export of your configuration, packed inside a feature module, which includes:
    • The Feed type;
    • The content type selected on the processor;
    • Fields used on your content type;
    • Field storage items of your fields;
    • Optionally other configuration that is related.

If you want to be sure that I can install your configuration, try to enable the created feature module on a clean install.

djdevin’s picture

Version: 8.x-3.0-alpha8 » 8.x-3.x-dev
Category: Support request » Bug report
Status: Postponed (maintainer needs more info) » Active

Reproduced this on D8 and knew we saw something like this in D7 too #2920690: Field validation errors in Number field.

The issue is that Feeds is appending the value to the new entity instead of replacing it in setTarget()

The property has to have a default set like this:

    $fields['attended'] = BaseFieldDefinition::create('boolean')
      ->setLabel(t('Attended'))
      ->setDefaultValue(FALSE)
      ->setRequired(FALSE)
      ->setRevisionable(TRUE);

That causes "Attended (attended): Attended: this field cannot hold more than 1 values."

Removing the default value worked:

    $fields['attended'] = BaseFieldDefinition::create('boolean')
      ->setLabel(t('Attended'))
      ->setRequired(FALSE)
      ->setRevisionable(TRUE);

It appears that on Entity creation, Feeds appended the value to the default.

djdevin’s picture

Status: Active » Needs review
StatusFileSize
new956 bytes

Fixes it specifically for single valued fields.

Status: Needs review » Needs work

The last submitted patch, 9: 3155046-replace-single-value-fields.patch, failed testing. View results

yassersamman’s picture

This issue also appears in boolean fields.
The patch #9 fixes the issue for me, but I can't confirm if this is a complete solution yet.

megachriz’s picture

So this issue occurs on at least base fields that set a default value? Interesting.

@djdevin
Do you want to write a kernel test for this bug?

djdevin’s picture

Yes, I'd like to get into it a bit more though. This is the first time I have looked at D8 feeds (bringing functionality over from D7).

megachriz’s picture

I also ran into this error for a custom entity type. EntityProcessorBase::clearTarget() currently checks if an entity implements TranslatableInterface, which ContentEntityBase already does, so that check almost has no value (because practically all supported content entity types extend that class). So this makes me think that this issue happens for non-translatable entities.

In my case, the issue is fixed when I add the following check to the clearTarget() method:

$entity->isTranslatable()

Attached a patch that adds this + a kernel test.

I'm not sure if this fixes the issue as well for when a base field provides a default value. It would be interesting to have a test for that case as well.

mindaugasd’s picture

I had this error importing 'feeds_feed' entities:

Title (title): Title: this field cannot hold more than 1 values.
Source (source): Source: this field cannot hold more than 1 values.

Import was working initially, but then it stopped working one day.

This patch fixed the problem.

kristi wachter’s picture

Just another confirmation:

I, too, was getting

Title (title): Title: this field cannot hold more than 1 values.

when importing CSV from one site to another. The patch in #14 fixed it for me and my import worked correctly.

Thank you!

megachriz’s picture

Status: Needs work » Needs review
StatusFileSize
new5.17 KB
new1.39 KB

In some of the multilingual tests $entity->isTranslatable() returned FALSE because the entity bundle was not set as translatable. This can be set as translatable with the service "content_translation.manager".

Let's see if that fixes the tests.

There are no functional changes in this patch, only changes in the tests.

glynster’s picture

+1 RTBC this patch helped us progress forward with a useable feed import. This must have been something introduced recently as our imports have not changed.

megachriz’s picture

StatusFileSize
new6.82 KB
new7.77 KB
new3.09 KB

Re #8

I tested the case of using a base field with a default value. I found out that this only caused an issue if the entity type was not translatable. For translatable entities, base fields with a default value did not cause any issue during my testing.

The fix I provided earlier also fixed the issue for the base field case.

In the patch I added a test for the base field case.

@glynster
Correct, this bug was introduced in Feeds 8.x-3.0-alpha7. In that release multilingual support was added.

The last submitted patch, 19: feeds-multivalue-3155046-19-tests-only.patch, failed testing. View results

  • MegaChriz committed 84741aa on 8.x-3.x
    Issue #3155046 by MegaChriz, djdevin, glynster: Fixed single value...
megachriz’s picture

Status: Needs review » Fixed

I think we're good to go. I did note some other issues related to translations, but that seem to be out of scope for this issue: I noticed imports could fail when configuring a field as non-translatable (on content translation settings page), but do select a language for it on the mapping screen.

Committed #19.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

mshdevx’s picture

StatusFileSize
new154.96 KB

Hi @MegaChriz

I think this is not fixed or I experienced new very similar issue, see my debugging:

feeds issue

Because FileFieldItemList returns also extra properties, which doesn't exist in $values it appends existing values (the same goes for single image field).

array (
  'target_id' => '6',
  'alt' => NULL,
  'title' => NULL,
  'width' => '323',
  'height' => '452',
)
kopfduenger’s picture

StatusFileSize
new35.59 KB

Hi @MegaChriz,

unfortunately, this issue for single value fields is still not resolved, at least for date fields. My content type is translatable, even the date field (although this does not make sense for a date field in my opinion).

While importing the tag <pubDate>...</pubDate> into a date field, the import fails due to:

Veröffentlicht am (field_date): Veröffentlicht am: this field cannot hold more than 1 values.
Please check your mappings.

translatable and required

kopfduenger’s picture

Hi @MegaChriz,

sorry, my fault: I could solve my issue above with:
- install module feed_ex
- changing the XPath statement for this field in feeds_tamper
and
- installing the patch in this comment: https://www.drupal.org/project/feeds/issues/3172709#comment-14999631

In order to make it work, I had to use these settings:

context: /rss/channel/item
XPath value: pubDate
both option fields checked for this 'custom source':
- raw value
- inner xml.