Can't create feed by uploading a file

Created on 11 October 2024, 7 months ago
Updated 14 October 2024, 6 months ago

When adding a feed of a Feed Type that has "Upload file" as the Fetcher value, an error, "Cannot upload file" is displayed in the UI when selecting a file of the correct extension using the "Choose File" dialog

Recent logs shows

Warning: Undefined array key "#field_name" in file_managed_file_save_upload() (line 998 of /var/www/html/web/core/modules/file/file.module)
#0 /var/www/html/web/core/includes/bootstrap.inc(166): _drupal_error_handler_real()
#1 /var/www/html/web/core/modules/file/file.module(998): _drupal_error_handler()
#2 /var/www/html/web/core/modules/file/src/Element/ManagedFile.php(76): file_managed_file_save_upload()
#3 [internal function]: Drupal\file\Element\ManagedFile::valueCallback()
#4 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(1259): call_user_func_array()
#5 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(999): Drupal\Core\Form\FormBuilder->handleInputElement()
#6 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(1069): Drupal\Core\Form\FormBuilder->doBuildForm()
#7 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(1069): Drupal\Core\Form\FormBuilder->doBuildForm()
#8 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(1069): Drupal\Core\Form\FormBuilder->doBuildForm()
#9 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(449): Drupal\Core\Form\FormBuilder->doBuildForm()
#10 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(633): Drupal\Core\Form\FormBuilder->rebuildForm()
#11 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(326): Drupal\Core\Form\FormBuilder->processForm()
#12 /var/www/html/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#13 [internal function]: Drupal\Core\Controller\FormController->getContentResult()
#14 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#15 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#16 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#17 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#18 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#19 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#20 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#21 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#22 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#23 /var/www/html/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#24 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#25 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#26 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#27 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#28 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#29 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#30 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#31 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#32 {main}
🐛 Bug report
Status

Postponed: needs info

Component

User interface

Created by

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇱Netherlands megachriz

    Do you have any additional file related modules installed? It has been reported before that one messed things up for Feeds. I don't remember which module it exactly was, but it could be that it was "File Entity".

  • 🇳🇱Netherlands megachriz

    I see that this happens when the configured upload directory on the feed type is not writable.

    Go to your feed type, and on "Fetcher settings", check which upload directory you have configured there. Then check if the file permissions on your system are set correctly for that directory. Or the parent directory if the directory does not exist yet. If it is set to "private://feeds" (the default), then your site may have an issue with writing files to the private file system. If it is set to "public://feeds" (the default if there is no private file system), then there is an issue with the public file system instead. You can see on /admin/config/media/file-system which directories are used for the public and private file system.

    As for the log message, this is caused by a bug in Drupal Core: #1903010: Notice: Undefined index: #field_name in file_managed_file_save_upload() .

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

  • 🇬🇧United Kingdom mcswann

    This may be totally the wrong way to do this but posting my solution here incase it helps/someone can correct me.

    I am running my drupal 10 site using ddev on macOS. This did turn out to be a file permission/ownership issue.

    To check permissions with the default public file system, run
    ddev ssh
    cd /var/www/html/web/sites/default/files
    ls -la

    Which outputted:

    drwxr-xr-x 10 [username] dialout  320 Nov 10 13:36 .
    drwxr-xr-x  8 [username] dialout  256 Nov 10 13:28 ..
    -r--r--r--  1 [username] dialout  486 Nov  9 14:42 .htaccess
    drwxrwxr-x  3 [username] dialout   96 Nov 10 13:18 2024-11
    drwxrwxr-x 58 [username] dialout 1856 Nov 10 14:01 css
    drwxrwxr-x  5 root     root     160 Nov 10 15:37 feeds
    drwxrwxr-x 50 [username] dialout 1600 Nov 10 14:01 js
    drwxrwxrwx  2 [username] dialout   64 Nov  9 15:43 php
    drwxrwxr-x  3 [username] dialout   96 Nov 10 13:18 styles
    drwxr-xr-x  3 [username] dialout   96 Nov  9 14:42 sync
    

    For some reason the automatically generated feeds directory is owned by root instead of [username] like the others ([username] as a placeholder for my actual username).

    chat gpt gave me this code to run
    sudo chown -R [username]:dialout /var/www/html/web/sites/default/files/feeds
    again replacing [username] with your actual user

    I believe dialout isn't actually essential here but it matched the others for me so i figured it made sense to keep it.

    I'm not sure if this is going to give me trouble down the line/there's something more fundamentally wrong with my setup but it got me up and running so I'm going to consider it a win.

Production build 0.71.5 2024