Skip to content

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

Open
duncanmcclean wants to merge 2 commits into
6.xfrom
filesystem-get-fallback
Open

[6.x] Return the fallback when reading a file from a disk that throws#15185
duncanmcclean wants to merge 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Asset upload after sorting by lastModified fails, breaks asset list Unable to read file from location: asset meta on s3

1 participant