From 067cee2d41c28bb03e1712aac3bbce00c395ff56 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Sun, 25 Feb 2024 15:02:35 -0800 Subject: [PATCH] Oops, fix bug reading manifest assets when .svg is not present Ah right, I make this mistake a lot when doing `group_by` stuff: if there's no SVG, then `assets_by_ext[:svg]` is `nil`, not `[]`. Oh well! --- app/models/swf_asset.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/swf_asset.rb b/app/models/swf_asset.rb index 64d5f19c..858303b3 100644 --- a/app/models/swf_asset.rb +++ b/app/models/swf_asset.rb @@ -88,7 +88,10 @@ class SwfAsset < ApplicationRecord # (There's probably only one of each! I'm just going by the same logic # we've seen in the JS library case, that later entries are more likely # to be correct.) - { png: assets_by_ext[:png].last, svg: assets_by_ext[:svg].last } + { + png: assets_by_ext.fetch(:png, []).last, + svg: assets_by_ext.fetch(:svg, []).last, + } end rescue StandardError => error Rails.logger.error "Could not read URLs from manifest: #{error.full_message}"