Skip to content

Handle JSON-LD @type arrays with multiple types - #134

Draft
sethherr wants to merge 1 commit into
mainfrom
sethherr/fix-honeybadger-fault-133052862
Draft

Handle JSON-LD @type arrays with multiple types#134
sethherr wants to merge 1 commit into
mainfrom
sethherr/fix-honeybadger-fault-133052862

Conversation

@sethherr

Copy link
Copy Markdown
Member

Fixes a Honeybadger fault where UpdateCitationMetadataFromRatingsJob aborted on RuntimeError: Array with multiple values: ["Person", "Organization"] (fault 133052862).

  • JSON-LD lets a node declare multiple types — an author who is also the publishing org is "@type": ["Person", "Organization"]. MetadataJsonLdParser routed @type through val_or_first_item, which raises on any array with more than one element.
  • @type now goes through a type_key that picks the type this parser cares about (KEY_PRIORITY then PUBLISHER_KEY_PRIORITY, falling back to the first listed), so the example above keys as Organization and becomes eligible for publisher_name.
  • val_or_first_item's raise is left alone — it still guards the case it was meant for, an array of full JSON-LD objects where picking one silently drops data.

JSON-LD allows a node to declare multiple types (e.g. an author who is
also the publishing org: ["Person", "Organization"]). Routing @type
through val_or_first_item raised on those, aborting
UpdateCitationMetadataFromRatingsJob.

Pick the type this parser cares about instead, keeping val_or_first_item's
raise as a canary for the case it actually guards.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant