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

Handle arrays for metadata['description'] in addMetadata() #14

Closed
hadro opened this issue Sep 13, 2023 · 2 comments · Fixed by #22
Closed

Handle arrays for metadata['description'] in addMetadata() #14

hadro opened this issue Sep 13, 2023 · 2 comments · Fixed by #22
Assignees
Labels
bug Something isn't working

Comments

@hadro
Copy link
Collaborator

hadro commented Sep 13, 2023

Flagged by @barmintor on the IIIF community call:

Want to flag this - working: https://iiif.archive.org/iiif/2/annualreport00carn_14/manifest.json
broken: https://iiif.archive.org/iiif/3/annualreport00carn_14/manifest.json

At a quick glance, looks like it's failing because metadata['description'] is an array: https://archive.org/metadata/annualreport00carn_14

@hadro
Copy link
Collaborator Author

hadro commented Sep 13, 2023

The fix here is pretty simple, we need to make another use of the existing coerce_list() function to handle complexity in description fields.

Specifically,

Line 304:
item.summary = {"none": [metadata["description"]]}
should be:
item.summary = {"none": [coerce_list(metadata["description"])]}

and similarly Line 108:
child.summary = {"none": [item['description']]}
should be:
child.summary = {"none": [coerce_list(item["description"])]}

@digitaldogsbody CCing you again here, if you're making changes soon feel free to incorporate but if not I can do a PR in the coming days

@hadro hadro added the bug Something isn't working label Sep 13, 2023
@digitaldogsbody digitaldogsbody self-assigned this Sep 14, 2023
@digitaldogsbody
Copy link
Collaborator

For documentation purposes - I actually went with a slightly different fix here: Since summary is a language map (https://iiif.io/api/presentation/3.0/#summary), it can have an array of values, and the issue was that we were double-wrapping it so it became "summary": {"none": [["value 1", "value 2"]]}.

I've fixed it by adding a conditional that only wraps the value in a list if it isn't already, otherwise it passes it through as-is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants