fix: skip malformed list entries instead of crashing the whole list - #4141
Open
michadasis wants to merge 1 commit into
Open
michadasis wants to merge 1 commit into
michadasis wants to merge 1 commit into
Conversation
AniList can return mediaList entries with a null media node (deleted/merged media), and other providers can likewise hand back entries missing their expected nested objects (list_status, show, node, etc.), or a corrupted local-storage record. Every provider's prepareData() destructured these unconditionally, so a single bad entry threw and took down the entire bookmarks list / tracking widgets with a raw TypeError instead of just omitting that one entry. Possibly related to MALSync#4122, MALSync#4136 (matching error text), but not confirmed against those specific reports - see PR description for caveats.
michadasis
force-pushed
the
fix/list-provider-null-entry-crash
branch
from
August 9, 2026 21:27
820289a to
3f97447
Compare
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
While looking at #4122 and #4136 (two recent crash reports with the exact error text "Cannot read properties of undefined (reading 'status')" / "(reading 'id')"), I found that every provider's list-loading code (
prepareData) destructures each raw list entry's nested fields unconditionally (el.media.id,el.list_status.status,el.show.ids, etc.), with no guard for malformed/incomplete entries. AniList in particular can returnmediaListentries with anullmedia node, and a local-storage record can end upundefinedafter a partial/corrupted write. A single such entry currently throws and takes down the entire list render (bookmarks grid, tracking widgets) instead of just being skipped.Important caveat: I have not been able to conclusively confirm that this is the exact crash behind #4122/#4136 — I tried decoding the minified background-console stack trace from #4136's screenshot against a matching build, but byte offsets in a 292KB minified bundle shift with every commit, so I can't verify it lines up with confidence. I'm not claiming "fixes" those issues (not using the auto-close keyword on purpose) — this is a real, independently-verifiable class of bug worth hardening regardless, but maintainers/reporters should confirm whether it actually matches their repro before closing those reports.
Changes
Same defensive pattern applied consistently across all list providers - skip the malformed entry (
con.error+continue) instead of letting one bad record crash the whole list:AniList/list.ts: skip entries with a missing/nullmedianode; also guardres.data.Pagebefore use (same crash shape as the earlier Cannot read properties of undefined (reading 'Page') #3755/Cannot read properties of undefined (reading 'Page') on Anilist in list sync page #3756 reports) so an unexpected/malformed API response throws a clear, catchable error instead of a raw property-access crash.Local/list.ts: skip falsy entries when iterating the local sync store.MyAnimeList_api/list.ts: skip entries missingnode/list_status.Kitsu/list.ts: skip entries with missinglist/el/attributes.Simkl/list.ts: skip entries missingshow.Shikimori/list.ts: skip entries with no matching metadata.MangaBaka/list.ts: skip entries missingSeries(in bothprepareDataand the fire-and-forgetcacheList).Test plan
test/src/provider/AniList/list.test.tsandtest/src/provider/local/list.test.tscovering the null-media / malformed-entry skip behavior.npm run test:ts:ci— all 929 tests pass (927 pre-existing + 2 new).npm run lint:script:ci— no new lint errors introduced.tsc --noEmiton bothtsconfig.jsonandtsconfig.node.json— no new type errors.