Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(API): Catastrophic 500 when media cannot be processed #976

Merged
merged 2 commits into from
Oct 19, 2023

Conversation

lauramosher
Copy link
Contributor

This fixes an issue with the Explore API where when a Community Map is loaded stories are requested, the Story sidebar hangs forever. After looking into it, we noticed there was a catastrophic error on the backend from ffmpeg trying to process media that couldn't actually be processed.

Adds red spec for showing the error and code to make that spec green.

The documentation on representation(opts).processed suggested that checking representable? would ensure we don't attempt to process media that can't be variable or previewable. It appears that we needed additional guards when processing the preview or variant, as these can fail despite the processor accepting the blob. Since the current solution is to catch all errors originating from Active Storage, we only included one spec for one of the possible errors.

When an otherwise representable media attachment is processed for a
preview or image and errors, the request fails catastrophically
resulting in the Explore interface looking like it's loading forever.

It was determined that this was due to the underlying processing failure
and, as such, the check for `.representable?` was insufficient to catch
errors.

For now, we simply added a test that raises the error manually for
invariable images. See https://api.rubyonrails.org/classes/ActiveStorage/Blob/Representable.html#method-i-variant

Our code currently catches any ActiveStorage::Error to reduce friction
points since the Explore code has guardrails in place to display other
media when a preview thumbnail is unaavilable.
@rudokemper rudokemper merged commit d2d5b56 into master Oct 19, 2023
@rudokemper rudokemper deleted the fix/lm-storage-variant-error branch November 7, 2023 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants