Skip to content

[6.x] Return the fallback when reading a file from a disk that throws - #15185

Merged
jasonvarga merged 2 commits into
6.xfrom
filesystem-get-fallback
Aug 14, 2026
Merged

[6.x] Return the fallback when reading a file from a disk that throws#15185
jasonvarga merged 2 commits into
6.xfrom
filesystem-get-fallback

Conversation

@duncanmcclean

@duncanmcclean duncanmcclean commented Aug 13, 2026

Copy link
Copy Markdown
Member

This pull request fixes an issue where a missing asset meta file would break the asset browser on any disk configured with 'throw' => true, with Unable to read file from location: .meta/example.jpg.yaml.

This was happening because Statamic\Filesystem\AbstractAdapter::get() only caught Illuminate\Contracts\Filesystem\FileNotFoundException, which Storage disks stopped throwing in Laravel 9.

On a disk with throw enabled, Laravel rethrows League\Flysystem\UnableToReadFile instead, so the exception escaped get() rather than returning the fallback. Asset::meta() relies on that fallback to know it needs to generate a missing meta file, so meta was never generated and the whole listing went down. It's not S3-specific — it affects any disk with throw enabled, which is why it's also been reported on SFTP.

This PR fixes it by catching UnableToReadFile as well. The FileNotFoundException catch has to stay: AbstractAdapter is shared by FlysystemAdapter, which wraps a Storage disk, and FilesystemAdapter, which wraps Illuminate\Filesystem\Filesystem — and the latter still throws it today.

There are two routes to the same failed read, and this PR covers both with tests:

  • Browsing assets that never had meta (uploaded directly to the disk) hits it via Asset::meta()
  • Uploading while the last_modified index is in use hits it via the indexer, which calls lastModified() during $store->save() — before AssetRepository::save() writes the meta file.

Fixes #8641
Fixes #11961
Related: #11966

duncanmcclean and others added 2 commits August 13, 2026 09:30
`AbstractAdapter::get()` only caught `FileNotFoundException`, which
`Storage` disks stopped throwing in Laravel 9. On a disk configured with
`throw`, `League\Flysystem\UnableToReadFile` escaped instead, so
`Asset::meta()` never received its fallback and missing meta files were
never generated.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…s in use

Covers the other route to the same missing meta read: the indexer calls
`lastModified()` during `$store->save()`, before `AssetRepository::save()`
writes the meta file.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@jasonvarga
jasonvarga merged commit 6e0ce9f into 6.x Aug 14, 2026
66 checks passed
@jasonvarga
jasonvarga deleted the filesystem-get-fallback branch August 14, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants