While trying to create a new CSV feed type, whenever changing the fetcher to 'csv', we receive the following ajax error:

AjaxError:
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /admin/structure/feeds/add?ajax_form=1
StatusText: OK
ResponseText:
( ! ) Notice: Undefined index: allowed_extensions in /var/www/html/web/modules/contrib/feeds/src/Feeds/Fetcher/Form/UploadFetcherForm.php on line 72
Call Stack
#TimeMemoryFunctionLocation
10.0026398768{main}( ).../index.php:0
20.0108587296Drupal\Core\DrupalKernel->handle( ).../index.php:19
30.03721875288Stack\StackedHttpKernel->handle( ).../DrupalKernel.php:693
40.03721875288Drupal\Core\StackMiddleware\NegotiationMiddleware->handle( ).../StackedHttpKernel.php:23
50.03721875984Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle( ).../NegotiationMiddleware.php:52
60.03721875984Drupal\page_cache\StackMiddleware\PageCache->handle( ).../ReverseProxyMiddleware.php:47
70.03721875984Drupal\page_cache\StackMiddleware\PageCache->pass( ).../PageCache.php:78
80.03731875984Drupal\Core\StackMiddleware\KernelPreHandle->h… ajax.js:98:32

Issue fork feeds-3031019

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pfrilling created an issue. See original summary.

pfrilling’s picture

StatusFileSize
new923 bytes

The attached should fix this issue.

megachriz’s picture

Status: Active » Postponed (maintainer needs more info)

I cannot reproduce this error. Can you describe what you do exactly? For example, did you select 'Upload file' first? Is your website slow? In my case changing fetcher, parser or processor happens in the blink of an eye.

pfrilling’s picture

1. Using Firefox (and Opera).
2. We browse to: /admin/structure/feeds/add
3. We change 'fetcher' from 'download from url' to 'upload file' and the ajax error happens immediately.

The site is running locally using DDEV v1.5.2, Docker Desktop 2.0.0.2 on a Mac using OS 10.14.2. The performance of the site is normal, definitely not slow.
--

We do not receive the ajax error when we:

1. Browse to: /admin/structure/feeds/add
2. We change Fetcher from 'download from url' to 'Directory'
3. Then, we change 'Directory' to 'Upload file'.

Let me know if you need any additional information.

pfrilling’s picture

Status: Postponed (maintainer needs more info) » Active

Sorry, I forgot to change the status back to active.

megachriz’s picture

I just saw that the error reported in this issue was logged. I only don't receive the AJAX error on screen for some reason.

The question then is: why is Feeds performing form validations when changing fetcher, parser or processor? I think the form validation implementation should be confident that fields defined in buildForm() should be available. So I think the patch in #2 only fixes a symptom of the issue.

ivnish’s picture

Same problem as #4.

hmendes’s picture

Status: Active » Needs review
StatusFileSize
new479 bytes

I was trying to understand this issue and about why is Feeds performing form validations when changing fetcher, parser or processor? : theses fields have an ajax callback, and AKAIK, when I have an ajax callback, it will call the validate function method ( i even saw a bunch of issues in core asking to implement an option to prevent this behavior )

So the flow is smt like:

Change the field (fetcher, parser or processor) -> validateForm() -> form() -> ajaxCallback()

And the field is only updated on the form(), after the validateForm is executed, so when the validate calls the validateConfigurationForm from UploadFetcherForm.php, the values are not updated.

Sending a patch to review. I only added the $form_state->IsSubmitted() to the validateForm skip the function if it is called from a place other than submit.

carolpettirossi made their first commit to this issue’s fork.

carolpettirossi’s picture

StatusFileSize
new3.61 MB

I faced the error below when trying to created a "Upload from File" feed type (watch recorded screencast attached):

Warning: Undefined array key "allowed_extensions" in /var/www/docroot/modules/contrib/feeds/src/Feeds/Fetcher/Form/UploadFetcherForm.php on line 85

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/docroot/modules/contrib/feeds/src/Feeds/Fetcher/Form/UploadFetcherForm.php on line 85
The website encountered an unexpected error. Please try again later.
TypeError: Drupal\feeds\Plugin\Type\ExternalPluginFormBase::submitConfigurationForm(): Argument #1 ($form) must be of type array, null given, called in /var/www/docroot/modules/contrib/feeds/src/FeedTypeForm.php on line 342 in Drupal\feeds\Plugin\Type\ExternalPluginFormBase->submitConfigurationForm() (line 43 of modules/contrib/feeds/src/Plugin/Type/ExternalPluginFormBase.php).

The patch suggested in #8 could not be applied on 8.x-3.0-beta2

I'm creating a Merge Request with the same code from #8.

Hopefully, it can be pushed to a new release soon ;)

carolpettirossi’s picture

MR !93 is the correct one. Sorry for creating MR 92 by mistake.

jsutta’s picture

#12 worked for me in Drupal 9.5.2 with Feeds 8.x-3.0-beta3. Thank you @carolpettirossi!

chriswinger’s picture

#12 worked for me too in Drupal 9.5.10 and Feeds 8.x-3.0-beta4. It resolved the error when creating a feed using an "Upload from File" feed type.

chriswinger’s picture

Status: Needs review » Reviewed & tested by the community
caspervoogt’s picture

#12 worked a treat for me.

megachriz’s picture

I've added test coverage for this issue. I had been working on these tests a while ago, but they were somehow failing. It looks like there's another error when trying to use the upload fetcher when the file module is not installed. But that's something for an other issue.

I closed MR 93 because I had trouble pushing code to it, because its branch name was the same as the branch in the Feeds repository. So I pushed the changes to a new branch called 3031019-fix.

The tests in branch 3031019-tests_only should fail.

caspervoogt’s picture

I had just queued two tests on #12 right before you posted here, Chris. I see they passed.

  • MegaChriz committed d47a7db6 on 8.x-3.x
    Issue #3031019 by MegaChriz, carolpettirossi, pfrilling, hmendes,...
megachriz’s picture

Status: Reviewed & tested by the community » Fixed

It looks like there is no easy way to catch logged errors during a FunctionalJavascript test. So I went ahead and just merged this. Thanks all!

Status: Fixed » Closed (fixed)

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

imclean’s picture

I'm still seeing this error with Feeds 3.2. The workaround in #4 avoids the issue.

This also resolves another issue:

TypeError: Drupal\feeds\Plugin\Type\ExternalPluginFormBase::submitConfigurationForm(): Argument #1 ($form) must be of type array, null given, called in /web/modules/contrib/feeds/src/FeedTypeForm.php on line 358 in Drupal\feeds\Plugin\Type\ExternalPluginFormBase->submitConfigurationForm() (line 43 of /web/modules/contrib/feeds/src/Plugin/Type/ExternalPluginFormBase.php).