[GH-ISSUE #6347] Character editor Lorebook tab crashes when an embedded lorebook entry has no secondary_keys #3544

Closed
opened 2026-10-21 06:04:08 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @stonebystone on GitHub (Sep 19, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6347

Problem

Opening a character card and scrolling to the Lorebook tab throws:

Cannot read properties of undefined (reading 'length')

The embedded-lorebook entry list in CharacterEditor.tsx renders entry.secondary_keys.length and entry.keys.join(...) directly. Character Card V2 makes secondary_keys optional, and cards imported from JSON or PNG keep whatever the author wrote, so a book where some entries omit the field crashes the tab. Reproduced on a card whose 12-entry embedded book has 6 entries without secondary_keys. The ST importer normalizes these arrays, but other import paths and hand-authored cards do not.

Proposal

  • Add a small shared helper that reads an entry's keys and secondary_keys defensively (missing or non-array → empty list, trimmed strings only).
  • Use it in the Character editor's embedded-lorebook list.
  • Regression covering complete, partial, empty, and malformed entries.

Owner: @stonebystone (implemented with Claude Code).

Originally created by @stonebystone on GitHub (Sep 19, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6347 ## Problem Opening a character card and scrolling to the Lorebook tab throws: ``` Cannot read properties of undefined (reading 'length') ``` The embedded-lorebook entry list in `CharacterEditor.tsx` renders `entry.secondary_keys.length` and `entry.keys.join(...)` directly. Character Card V2 makes `secondary_keys` optional, and cards imported from JSON or PNG keep whatever the author wrote, so a book where some entries omit the field crashes the tab. Reproduced on a card whose 12-entry embedded book has 6 entries without `secondary_keys`. The ST importer normalizes these arrays, but other import paths and hand-authored cards do not. ## Proposal - Add a small shared helper that reads an entry's `keys` and `secondary_keys` defensively (missing or non-array → empty list, trimmed strings only). - Use it in the Character editor's embedded-lorebook list. - Regression covering complete, partial, empty, and malformed entries. Owner: @stonebystone (implemented with Claude Code).
Author
Owner

@stonebystone commented on GitHub (Sep 19, 2026):

Closing: the reporter fixed the affected card's data locally and does not plan a PR. The crash itself (unguarded entry.secondary_keys.length in the Character editor's embedded-lorebook list, for V2 cards that omit the optional field) is still real if a maintainer wants to pick it up.

<!-- gh-comment-id:5739784474 --> @stonebystone commented on GitHub (Sep 19, 2026): Closing: the reporter fixed the affected card's data locally and does not plan a PR. The crash itself (unguarded `entry.secondary_keys.length` in the Character editor's embedded-lorebook list, for V2 cards that omit the optional field) is still real if a maintainer wants to pick it up.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#3544
No description provided.