Skip to content

fix: skip malformed list entries instead of crashing the whole list - #4141

Open
michadasis wants to merge 1 commit into
MALSync:masterfrom
michadasis:fix/list-provider-null-entry-crash
Open

michadasis wants to merge 1 commit into
MALSync:masterfrom
michadasis:fix/list-provider-null-entry-crash

Conversation

@michadasis

@michadasis michadasis commented Aug 9, 2026 •

Copy link
Copy Markdown

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 return mediaList entries with a null media node, and a local-storage record can end up undefined after 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/null media node; also guard res.data.Page before 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 missing node/list_status.
  • Kitsu/list.ts: skip entries with missing list/el/attributes.
  • Simkl/list.ts: skip entries missing show.
  • Shikimori/list.ts: skip entries with no matching metadata.
  • MangaBaka/list.ts: skip entries missing Series (in both prepareData and the fire-and-forget cacheList).

Test plan

  • Added test/src/provider/AniList/list.test.ts and test/src/provider/local/list.test.ts covering 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 --noEmit on both tsconfig.json and tsconfig.node.json — no new type errors.
  • Not verified against the actual reported crash (see caveat above) — would appreciate a reporter or maintainer confirming/refuting against Sign in and authentication issue #4122/Extension crashing #4136 before relying on this as the fix for those specific issues.

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
michadasis force-pushed the fix/list-provider-null-entry-crash branch from 820289a to 3f97447 Compare August 9, 2026 21:27

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