Skip to content

Decode Jellyfin items with unknown person kinds - #1604

Draft
pablofontanilla wants to merge 1 commit into
TortugaPower:developfrom
pablofontanilla:fix/jellyfin-narrator-decoding
Draft

pablofontanilla wants to merge 1 commit into
TortugaPower:developfrom
pablofontanilla:fix/jellyfin-narrator-decoding

Conversation

@pablofontanilla

Copy link
Copy Markdown

Summary

Refs #1602. The Jellyfin details screen fails with "The data couldn't be read because it isn't in the correct format." when an item credits a person with Type: "Narrator".

The cause is jellyfin-sdk-swift 0.4.0: its PersonKind has no narrator case, so one such person makes the whole BaseItemDto fail to decode. This PR makes the two decode sites that request People lenient. It does not bump the SDK.

  • fetchItemDetails: gets the raw response (client.data(for:)) and decodes it with the new decodeLeniently. It first decodes normally. Only if that fails with a DecodingError, it sets unknown Type values inside People arrays to "Unknown" and decodes again. Other decode errors still throw. The date formats are the same as the SDK's OpenISO8601DateFormatter (its initializer is internal in 0.4).
  • fetchNarrators: decodes only the fields it reads (Name, Id, Role, Type) into a small private struct, with Type as a String. On our server, narrators have "Role": "" and the kind only in Type, so replacing the type with "Unknown" would hide them. The narrator logic is the same as before.
  • Both calls go through a new send(_ operation:), which keeps the noClient guard and the 401/403 → sessionExpired mapping of send(_ request:).

No new files and no project.pbxproj changes. The tests are in the existing IntegrationConnectionDataDecodingTests.swift.

Overlap with #1586

#1586 keeps the SDK at 0.4, so it does not fix this. It adds one more send(Paths.getItem(itemID:)) call site, fetchItem(for:), which fails in the same way for these items. If this PR merges first, that call can use decodeLeniently the same way as fetchItemDetails.

@GianniCarlo, you can pick the merge order. If you prefer, I can rebase this PR onto #1586.

A later, separate PR can bump jellyfin-sdk-swift (the narrator case exists in 3.x). The lenient decode still protects against the next kind that a newer server adds.

Tests

  • New JellyfinPeopleDecodingTests (3 tests): an item with a "Narrator" person decodes (the person becomes .unknown, dates still decode); a decode error not caused by People still throws; narrators are found by type or role.
  • Unit Tests plan (BookPlayerTests), iPhone 17 simulator: 536/536 pass.
  • Manual test on a Jellyfin 12.1.0 server (iPhone 17 simulator): the details screens of two audiobooks with a "Narrator" person load, with no error and no decode lines in the console. Before, both failed with the error above.
  • fetchNarrators is tested by the unit test only: on develop, the Jellyfin library has only the Books and Authors tabs, so no screen calls it.

🤖 Generated with Claude Code

jellyfin-sdk-swift 0.4 has no `PersonKind` case for "Narrator". When an
item credits a person with `Type: "Narrator"`, the whole response fails
to decode, and the details screen shows "The data couldn't be read
because it isn't in the correct format."

`fetchItemDetails` now decodes the raw response itself. If the normal
decode fails, it replaces unknown `People[].Type` values with "Unknown"
and decodes again. Other decode errors still throw.

`fetchNarrators` decodes only the fields it reads, with the person type
as a `String`, so narrators are found by type again.

Refs TortugaPower#1602

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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