From fb2bdd6ea52d3f4d5c7030ce2d1b0db21fa961a3 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Sun, 25 Feb 2024 16:05:43 -0800 Subject: [PATCH] Fix crash when dealing with 404'd manifests First off, I think our code has converged on a convention of gracefully returning `nil` for manifest-less situations, so we can do that instead of raise! And then that lets us just simplify this check to whether `manifest` is present, instead of `manifest_url`, so we stop crashing in cases where we get to this point in the code and there's a manifest URL but not a manifest. --- app/models/swf_asset.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/swf_asset.rb b/app/models/swf_asset.rb index 91b36ba7..c886eabd 100644 --- a/app/models/swf_asset.rb +++ b/app/models/swf_asset.rb @@ -59,7 +59,7 @@ class SwfAsset < ApplicationRecord end def load_manifest(return_content: true, save_changes: true) - raise "manifest_url is blank" if manifest_url.blank? + return nil if manifest_url.blank? # If we recently tried loading the manifest and got a 4xx HTTP status code # (e.g. a 404, there's a surprising amount of these!), don't try again. But @@ -109,7 +109,7 @@ class SwfAsset < ApplicationRecord MANIFEST_BASE_URL = Addressable::URI.parse("https://images.neopets.com") def manifest_asset_urls - return {} if manifest_url.nil? + return {} unless manifest.present? begin # Organize the asset URLs by file extension, convert them from paths to