Decode Jellyfin items with unknown person kinds - #1604
Draft
pablofontanilla wants to merge 1 commit into
Draft
pablofontanilla wants to merge 1 commit into
pablofontanilla wants to merge 1 commit into
Conversation
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
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.
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-swift0.4.0: itsPersonKindhas nonarratorcase, so one such person makes the wholeBaseItemDtofail to decode. This PR makes the two decode sites that requestPeoplelenient. It does not bump the SDK.fetchItemDetails: gets the raw response (client.data(for:)) and decodes it with the newdecodeLeniently. It first decodes normally. Only if that fails with aDecodingError, it sets unknownTypevalues insidePeoplearrays to"Unknown"and decodes again. Other decode errors still throw. The date formats are the same as the SDK'sOpenISO8601DateFormatter(its initializer isinternalin 0.4).fetchNarrators: decodes only the fields it reads (Name,Id,Role,Type) into a small private struct, withTypeas aString. On our server, narrators have"Role": ""and the kind only inType, so replacing the type with"Unknown"would hide them. The narrator logic is the same as before.send(_ operation:), which keeps thenoClientguard and the 401/403 →sessionExpiredmapping ofsend(_ request:).No new files and no
project.pbxprojchanges. The tests are in the existingIntegrationConnectionDataDecodingTests.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 usedecodeLenientlythe same way asfetchItemDetails.@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(thenarratorcase exists in 3.x). The lenient decode still protects against the next kind that a newer server adds.Tests
JellyfinPeopleDecodingTests(3 tests): an item with a"Narrator"person decodes (the person becomes.unknown, dates still decode); a decode error not caused byPeoplestill throws; narrators are found by type or role.Unit Testsplan (BookPlayerTests), iPhone 17 simulator: 536/536 pass."Narrator"person load, with no error and no decode lines in the console. Before, both failed with the error above.fetchNarratorsis tested by the unit test only: ondevelop, the Jellyfin library has only the Books and Authors tabs, so no screen calls it.🤖 Generated with Claude Code