Stop 500ing on a v3 manifest that has no canvases - #414
Open
ShanaLMoore wants to merge 1 commit into
Open
ShanaLMoore wants to merge 1 commit into
ShanaLMoore wants to merge 1 commit into
Conversation
sanitize_v3 called `hash['items'].each` with no guard, so a manifest without an 'items' key raised NoMethodError and the work's viewer showed "Unable to load manifest". Two ways to get there: a work whose presenter yields no displayable file sets, and a v2-shaped hash sanitized as v3, which is what Hyrax's CachingIiifManifestBuilder produced until samvera/hyrax#7590. sanitize_v2 has always guarded its equivalent loop. The label scrub next to it used `Hash#key`, which takes a value, so it returned nil and the scrub never ran. Fixing it to a lookup means canvas labels now get scrubbed too, so both call sites go through one method that tolerates a missing label. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Story
Refs notch8/hykuup_knapsack#748
Expected Behavior Before Changes
sanitize_v3didhash['items'].eachwith no guard, so a manifest with noitemskey raisedNoMethodError (undefined method 'each' for nil)and the work's viewer showed "Unable to load manifest".sanitize_v2has always guarded the equivalent loop.Two ways to reach it: a work whose presenter yields no displayable file sets, and a v2-shaped hash sanitized as v3, which is what Hyrax's
CachingIiifManifestBuilderproduced until samvera/hyrax#7590 (it defaulted to the v2 factory whileIiifPrint.config.default_iiif_manifest_versionstayed 3). That combination took out roughly half the works on two production tenants.Expected Behavior After Changes
A manifest with no canvases is returned as-is instead of 500ing.
Notes
Hash#key, which takes a value, not a key, so it returned nil and the scrub never ran. Fixed to a lookup, which means canvas labels get scrubbed now too. Both call sites share one method that tolerates a missing label.Testing
spec/services/iiif_print/manifest_builder_service_decorator_spec.rbcovers the canvas-less manifest, the label unescape, and a manifest with no label. Not run locally (needs the full engine cart stack); CI runs the suite.🤖 Assisted-by: Opus 5