spicywebau / craft-embedded-assets

Manage YouTube videos, Instagram photos, Twitter posts and more as first class assets in Craft CMS
MIT License
171 stars 34 forks source link

Adding an asset fails with server error and Corrupted path detected - possibly due whitespace in title #215

Closed mike-moreau closed 2 years ago

mike-moreau commented 2 years ago

Description

Hey there!

Adding one particular new asset fails. A server error is thrown, and the following is found in the logs.

Screen shot shows a possible problem with a whitespace character.

2022-06-23 15:30:32 [-][14043][9m6nq33v5k481eair6e4purbe2][error][League\Flysystem\CorruptedPathDetected] League\Flysystem\CorruptedPathDetected: Corrupted path detected: How-to-Build-Trust-with-Franchise-Brokers-and-Gro.json in .../vendor/league/flysystem/src/CorruptedPathDetected.php:15
Stack trace:
#0 .../vendor/league/flysystem/src/Util.php(146): League\Flysystem\CorruptedPathDetected::forPath('How-to-\xEF\xBB\xBFBuild...')
#1 .../vendor/league/flysystem/src/Util.php(107): League\Flysystem\Util::removeFunkyWhiteSpace('How-to-\xEF\xBB\xBFBuild...')
#2 .../vendor/league/flysystem/src/Util.php(92): League\Flysystem\Util::normalizeRelativePath('How-to-\xEF\xBB\xBFBuild...')
#3 .../vendor/league/flysystem/src/Filesystem.php(56): League\Flysystem\Util::normalizePath('How-to-\xEF\xBB\xBFBuild...')
#4 .../vendor/craftcms/cms/src/base/FlysystemVolume.php(122): League\Flysystem\Filesystem->has('How-to-\xEF\xBB\xBFBuild...')
#5 .../vendor/craftcms/cms/src/services/Assets.php(885): craft\base\FlysystemVolume->fileExists('How-to-\xEF\xBB\xBFBuild...')
#6 .../vendor/craftcms/cms/src/services/Assets.php(888): craft\services\Assets->craft\services\{closure}('How-to-\xEF\xBB\xBFBuild...')

Steps to reproduce

  1. Attempt to add new asset with url https://www.youtube.com/watch?v=N1nequHmaZE
  2. Results in server error

Other information

Screen Shot 2022-06-23 at 8 56 41 PM
ttempleton commented 2 years ago

Thanks for reporting that - fixed now in Embedded Assets 2.11.1.

mike-moreau commented 2 years ago

Thanks for the quick reply.

I'm seeing a type error after updating to 2.11.1.

2022-06-24 07:18:53 [-][14043][qin5e34r3a223j6rt0bt144efa][error][TypeError] TypeError: spicyweb\embeddedassets\Service::createAsset(): Return value must be of type craft\elements\Asset, string returned in .../vendor/spicyweb/craft-embedded-assets/src/Service.php:333
Stack trace:
#0 .../vendor/spicyweb/craft-embedded-assets/src/Controller.php(53): spicyweb\embeddedassets\Service->createAsset(Object(spicyweb\embeddedassets\models\EmbeddedAsset), Object(craft\models\VolumeFolder))
#1 [internal function]: spicyweb\embeddedassets\Controller->actionSave()
...
ttempleton commented 2 years ago

Whoops, there was a bit of a typo where it was trying to return the sanitised filename instead of setting it on the asset - not really sure how that was working for me, but anyway... That should now be working properly in 2.11.2, but please let me know if any other issues come up.

mike-moreau commented 2 years ago

That's working perfectly. Thanks again!