[GH-ISSUE #667] [Issue]: CharacterEditor crashes opening characters with new-format avatarCrop after PR #666 revert #315

Closed
opened 2026-10-20 17:27:34 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Romuromylus on GitHub (May 11, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/667

Summary

After PR #666 reverted PR #661, the legacy CharacterEditor crashes (blank screen + TypeError: can't access property "toFixed", v.zoom is undefined) when opening any character whose extensions.avatarCrop was saved during the brief window PR #661 was live. Those crops are in the new {srcX, srcY, srcWidth, srcHeight} shape; the reverted editor reads .zoom directly.

Expected behavior

Opening a character with a foreign-shape avatarCrop should not crash. The cropper widget should fall back to the default (zoom 1, offset 0,0) and let the user re-edit or just save (which overwrites the foreign shape with the legacy one).

Actual behavior

packages/client/src/components/characters/CharacterEditor.tsx reads crop.zoom.toFixed(2) directly. When the saved crop lacks .zoom, the editor throws and renders a blank screen. The character cannot be opened at all.

Console error:

Uncaught TypeError: can't access property "toFixed", v.zoom is undefined
    at CharacterEditor (CharacterEditor-Du_Qx-gv.js:1)

getAvatarCropStyle in packages/client/src/lib/utils.ts has the same shape assumption — it produces invalid CSS (scale(undefined) translate(undefined%, undefined%)) for foreign-shape crops. Doesn't crash, but silently fails to apply any transform.

Steps to reproduce

  1. On a pre-revert build of main (anywhere between PR #661 merging and PR #666 merging), open a character and save a crop using the new cropper widget. The crop persists as {srcX, srcY, srcWidth, srcHeight} in extensions.avatarCrop.
  2. Pull/update to post-#666 main (the revert is now active; legacy slider-based cropper is restored).
  3. Open the same character in the editor.
  4. Editor crashes immediately with the console error above. Character cannot be opened.

Environment

  • Marinara Engine version: post-#666 (upstream main `0cb2f4e`)
  • Install type: source / Docker
  • OS + version: Windows 11
  • Browser or app shell: Firefox / Chrome (reproducible in both)

Logs, screenshots, or video

Console error stack:

Uncaught TypeError: can't access property "toFixed", v.zoom is undefined
    it http://127.0.0.1:7860/assets/CharacterEditor-Du_Qx-gv.js:1
    jc http://127.0.0.1:7860/assets/vendor-react-DOoS7PVg.js:8

Additional context

Edge case: only affects users who saved an avatarCrop with the new cropper during the PR #661 window. The fix is a defensive read — treat anything that isn't a legacy shape as "no crop" so the editor opens with the slider at the default and the user can re-edit cleanly.

Follow-up PR with the surgical patch is on the way (linked from this issue once filed).

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Romuromylus on GitHub (May 11, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/667 ## Summary After PR #666 reverted PR #661, the legacy CharacterEditor crashes (blank screen + `TypeError: can't access property "toFixed", v.zoom is undefined`) when opening any character whose `extensions.avatarCrop` was saved during the brief window PR #661 was live. Those crops are in the new `{srcX, srcY, srcWidth, srcHeight}` shape; the reverted editor reads `.zoom` directly. ## Expected behavior Opening a character with a foreign-shape `avatarCrop` should not crash. The cropper widget should fall back to the default (zoom 1, offset 0,0) and let the user re-edit or just save (which overwrites the foreign shape with the legacy one). ## Actual behavior `packages/client/src/components/characters/CharacterEditor.tsx` reads `crop.zoom.toFixed(2)` directly. When the saved crop lacks `.zoom`, the editor throws and renders a blank screen. The character cannot be opened at all. Console error: ``` Uncaught TypeError: can't access property "toFixed", v.zoom is undefined at CharacterEditor (CharacterEditor-Du_Qx-gv.js:1) ``` `getAvatarCropStyle` in `packages/client/src/lib/utils.ts` has the same shape assumption — it produces invalid CSS (`scale(undefined) translate(undefined%, undefined%)`) for foreign-shape crops. Doesn't crash, but silently fails to apply any transform. ## Steps to reproduce 1. On a pre-revert build of main (anywhere between PR #661 merging and PR #666 merging), open a character and save a crop using the new cropper widget. The crop persists as `{srcX, srcY, srcWidth, srcHeight}` in `extensions.avatarCrop`. 2. Pull/update to post-#666 main (the revert is now active; legacy slider-based cropper is restored). 3. Open the same character in the editor. 4. Editor crashes immediately with the console error above. Character cannot be opened. ## Environment - Marinara Engine version: post-#666 (upstream main \`0cb2f4e\`) - Install type: source / Docker - OS + version: Windows 11 - Browser or app shell: Firefox / Chrome (reproducible in both) ## Logs, screenshots, or video Console error stack: ``` Uncaught TypeError: can't access property "toFixed", v.zoom is undefined it http://127.0.0.1:7860/assets/CharacterEditor-Du_Qx-gv.js:1 jc http://127.0.0.1:7860/assets/vendor-react-DOoS7PVg.js:8 ``` ## Additional context Edge case: only affects users who saved an `avatarCrop` with the new cropper during the PR #661 window. The fix is a defensive read — treat anything that isn't a legacy shape as "no crop" so the editor opens with the slider at the default and the user can re-edit cleanly. Follow-up PR with the surgical patch is on the way (linked from this issue once filed). ## Template check - [ ] I DID NOT read this template and provide the requested details.
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#315
No description provided.