Problem/Motivation

When you are importing files from a http source, but the source contains a url to a non-existing file or the url is otherwise not correct, you could get an error like the following:

In this case it is not clear which url was not correct.

Steps to reproduce

  1. Install modules Node, Feeds, File
  2. Create a content type with a file field
  3. Create a feed type and map to this file field

Import a malformed url. While I don't know the exact url that explicitly caused cURL error 3: <url> malformed, here are some examples that do cause a curl error:

  • /sites/default/files/example.txt (domain name is missing)
  • https://www.example.com/sites/default/files/example.txt (404)
  • https://www.examp le.com/sites/default/files/example.txt (space in domain name)
  • custom://example.txt (unsupported protocol)

But in these situations the url that caused trouble is displayed already in the error message.

Proposed resolution

When an error occurs, make sure that the url that cause the error is displayed and throw it as a TargetValidationException.

Remaining tasks

  1. Test if the available code solves the problem.
  2. Write a test where a file download failed and assert that the expected message is displayed.

Tasks for a follow-up:

  1. Write a test where a file download still failed on a second import attempt and assert that the expected message is displayed again.
  2. (advanced) See if there is a way on subsequent imports that the user is warned again about the failed download.

User interface changes

Introduced terminology

API changes

Data model changes

Original report by Burlyn84

I have a client that wants to manage his parts online. There are 335 parts to upload and I have feeds set up to handle this from a CSV.

I keep getting this error after trying to upload some parts.

cURL error 3: malformed (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

Sometimes the error will include the information that certain values should not be null, which doesn't make sense because some of the parts will upload.

Any ideas? I have attached the configuration and the screenshot of the error.

Issue fork feeds-3023198

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

Burlyn84 created an issue. See original summary.

Burlyn84’s picture

I have figured out something here on this error.

I was calling for photos that didn't exist in the my csv file. I thought the feed would skip over that if there was no such file. But apparently not.

Is that something that could be added to this modules capabilities?

megachriz’s picture

Title: cURL error 3 » Display an understandable error message when source file contains links to non-existing files
Category: Bug report » Feature request
Priority: Major » Normal

I think if a file specified by the source doesn't exist, the item should not be imported. The import is "broken" after all, cause Feeds cannot import everything it is supposed to do. But it would be cool if Feeds would say that it couldn't find the file instead of displaying the curl error.

megachriz’s picture

Issue tags: +Feeds file target

There are more file target related issues. Tagging this with “Feeds file target”.

gantal’s picture

Issue tags: +DCCO2020

Tagging for DrupalCamp Colorado's upcoming contrib day.

megachriz’s picture

Status: Active » Needs review

I ran into this issue today, I made the error message slightly more informing. I did notice after trying to import it for a second time, the error was not repeated. This could be because I was still working on the error message at the time, but I think it would not be great if on subsequent imports the missing file is just ignored.

megachriz’s picture

Issue summary: View changes

Updated issue summary.

megachriz’s picture

Issue summary: View changes

I've written tests for this issue. However, I think that the error being displayed on subsequent imports is out of scope this issue. Because it turns out that on files missing the import still goes through. It looks like this wasn't always the case as reported in #3125127: Item fails to import when image for file target fails to download.
Perhaps it would be better if the item (optionally) fails validation if a file cannot be found, but that can be handled in an other issue, perhaps in #3125127: Item fails to import when image for file target fails to download.

I noticed the "fix" for this issue is also covered by #3565186: Add service for resolving files. So we could just wait till that one is merged and then only commit the test that is provided here. I wrote the tests based on FileResolver. The test testImportWith404Url() will fail here, because the error message used in the MR here isn't specialized for HTTP error codes yet, but FileResolver's implementation is.

megachriz’s picture

Status: Needs review » Fixed

I've scheduled the test coverage for merging! The actual fix happened already in #3565186: Add service for resolving files.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • megachriz committed bb58c225 on 8.x-3.x
    fix: #3023198 Display an understandable error message when source file...

Status: Fixed » Closed (fixed)

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