Skip to content

Return 404 when Active Storage representation blobs are missing - #173

Merged
thibaudgg merged 1 commit into
masterfrom
cursor/activestorage-missing-blob-404-4cd3
Sep 3, 2026
Merged

Return 404 when Active Storage representation blobs are missing#173
thibaudgg merged 1 commit into
masterfrom
cursor/activestorage-missing-blob-404-4cd3

Conversation

@thibaudgg

Copy link
Copy Markdown
Member

Why

Production AppSignal exception incident #370 is an ActiveStorage::FileNotFoundError from ActiveStorage::Representations::RedirectController#show:

S3Service#stream/download → Blob#open → PopplerPDFPreviewer#preview → Preview#processed → set_representation

Recent traces (rev 1811e08, tenants such as demo-de, blob id 131) 500 on GET representations/redirect because the blob record exists but the object is missing from S3. Rails already returns 404 for an invalid variation signature and for unprocessable image bytes (PR #172 / AppSignal #458); a missing storage object still raised.

What

  • Rescue ActiveStorage::FileNotFoundError next to InvalidSignature / Vips::Error / ImageProcessing::Error in ActiveStorage::Representations::BaseController#set_representation (head :not_found).
  • Same after_initialize + class_eval style as PR Return 404 when Active Storage image variants cannot be processed #172 (gem controller is not loaded while initializers run).
  • Cover a stored blob whose file was deleted: representation request → 404.

Do not merge or deploy from this PR. Leave the AppSignal incident open.

Open in Web Open in Cursor 

Rescue FileNotFoundError in representation show so a blob record
without a storage object returns 404 instead of 500 (AppSignal #370).

Co-authored-by: Thibaud Guillaume-Gentil <thibaud@thibaud.gg>
@thibaudgg
thibaudgg marked this pull request as ready for review September 3, 2026 18:59
@thibaudgg
thibaudgg merged commit 7a0cd8d into master Sep 3, 2026
3 of 4 checks passed
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.

2 participants