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
- Install modules Node, Feeds, File
- Create a content type with a file field
- 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
Test if the available code solves the problem.Write a test where a file download failed and assert that the expected message is displayed.
Tasks for a follow-up:
- Write a test where a file download still failed on a second import attempt and assert that the expected message is displayed again.
- (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.
| Comment | File | Size | Author |
|---|---|---|---|
| Screen Shot 2018-12-31 at 1.12.53 PM.png | 62.27 KB | Burlyn84 | |
| feedconfig.txt | 1.93 KB | Burlyn84 |
Issue fork feeds-3023198
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
Comment #2
Burlyn84 commentedI 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?
Comment #3
megachrizI 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.
Comment #4
megachrizThere are more file target related issues. Tagging this with “Feeds file target”.
Comment #5
gantal commentedTagging for DrupalCamp Colorado's upcoming contrib day.
Comment #7
megachrizI 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.
Comment #8
megachrizUpdated issue summary.
Comment #9
megachrizI'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.Comment #10
megachrizI've scheduled the test coverage for merging! The actual fix happened already in #3565186: Add service for resolving files.