Argument is wrong type after Explode tamper to set taxonomy

Created on 23 April 2025, 1 day ago

Problem/Motivation

I'm having an issue using the explode tamper to map to a taxonomy. In my use case, I have a feed definition setup that uses the Feed: Title as the source and then use the explode tamper to map the title to a specific taxonomy.

I have about 30 different feeds that use the same feed definition but the data on the feed is unique in terms of how it should be associated to the taxonomy.

A sample feed name might be: Lehigh|Activities or Lehigh|Residence Camp. The goal is to get the first instance to be associated with the taxonomy terms: Lehigh & Activities, and Lehigh & Residence Camp for the second instance.

There could be more then two terms in the feed name.

The taxonomy is setup to automatically create entities and the taxonomy field is configured to have an unlimited amount of terms.

I have the Explode tamper setup under the appropriate Feeds data. I'm using a | as the string separator and the limit is blank.

When I go to import the feed, I am getting the following error on the screen:

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /batch?id=117&op=do_nojs&op=do
StatusText: error
ResponseText: The website encountered an unexpected error. Try again later.TypeError: trim(): Argument #1 ($string) must be of type string, array given in trim() (line 269 of modules/contrib/feeds/src/Feeds/Target/EntityReference.php). Drupal\feeds\Feeds\Target\EntityReference->prepareValue() (Line: 117)
Drupal\feeds\Feeds\Target\EntityReference->setTarget() (Line: 1418)
Drupal\feeds\Feeds\Processor\EntityProcessorBase->map() (Line: 302)
Drupal\feeds\Feeds\Processor\EntityProcessorBase->process() (Line: 128)
Drupal\feeds\EventSubscriber\LazySubscriber->Drupal\feeds\EventSubscriber\{closure}() (Line: 206)
Symfony\Component\EventDispatcher\EventDispatcher->callListeners() (Line: 56)
Symfony\Component\EventDispatcher\EventDispatcher->dispatch() (Line: 41)
Drupal\feeds\FeedsExecutable->dispatchEvent() (Line: 267)
Drupal\feeds\FeedsExecutable->doProcess() (Line: 111)
Drupal\feeds\FeedsExecutable->processItem() (Line: 297)
_batch_process() (Line: 139)
_batch_do() (Line: 95)
_batch_page() (Line: 52)
Drupal\system\Controller\BatchController->batchPage()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 593)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 50)
Drupal\ban\BanMiddleware->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 49)
Drupal\remove_http_headers\StackMiddleware\RemoveHttpHeadersMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 709)
Drupal\Core\DrupalKernel->handle() (Line: 19)

I am using Feeds v8.x-3.0, Feeds Tamper v8.x-2.0-beta4, Tamper v8.x-1.0-beta1, and Drupal 11.1.6.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @wschwab
  • 🇳🇱Netherlands megachriz

    I tried to reproduce the issue using the following steps:

    1. Created a taxonomy called 'tags'.
    2. Created a content type called 'article' with a taxonomy reference field for the taxonomy 'tags' and allowing an unlimited number of values.
    3. Created a feed type using the CSV parser and the node processor with content type 'Article'.
    4. Add mappings to 'Title' and 'Tags'. Configured the mapping target 'Tags' to reference by name and to autocreate terms in the vocabulary 'tags'.
    5. Added a Tamper Explode plugin to the 'Tags' mapping target and using | as delimiter.
    6. Imported the following CSV file:
      title,tags
      Lorem,Lehigh|Activities
      Ipsum,Lehigh|Residence Camp
      

    My result was that two articles got imported, both with two terms.

    Can you share your configuration and provide a sample source file? This way I can probably quicker try to reproduce the issue. One way to share configuration is by packing it inside a feature module.

    Or else can you provide the exact steps to reproduce the issue?

Production build 0.71.5 2024