[GH-ISSUE #4789] [Issue]: Persona avatar updates can leave stale crop data or unsafe avatar files #2637

Closed
opened 2026-10-21 05:51:58 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Xelvanis on GitHub (Aug 9, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4789

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Persona avatar assignment and removal do not consistently treat the database reference, crop data, and local avatar file as one lifecycle. Some replacement paths retain crop data from the previous image, failures after writing a new file can leave that file unattached, and Mari Images can delete a file that Persona version history still references.

Expected behavior

  • Replacing or clearing a Persona avatar resets the crop that was calculated for the previous image.
  • If a newly written avatar cannot be attached to its Character or Persona record, the unattached file is removed.
  • Deleting a Persona avatar file removes it only after no current record or Persona version-history row references it.

Actual behavior

  • Direct upload, gallery, and Mari Images paths do not all reset avatarCrop when the underlying Persona image changes.
  • Direct upload, native import, and Mari Images assignment can write an avatar before the record update succeeds; some failure paths leave that file in data/avatars.
  • Mari Images clears the current Persona reference and can unlink its file without protecting the same path when it is retained by Persona history.

Steps to reproduce

  1. Create a Persona with an avatar and save a non-empty crop.
  2. Replace the avatar through direct upload, a gallery image, or Mari Images.
  3. Observe that affected paths can retain the crop from the previous image.
  4. Trigger a storage/update failure after an avatar file is written through direct upload, native import, or Mari Images assignment.
  5. Inspect data/avatars and observe that affected paths can leave the new file unattached.
  6. With an avatar path retained by Persona version history, clear the Persona avatar through Mari Images with file deletion enabled.
  7. Observe that the file can be deleted even though the history row still references it.

Environment

  • Marinara Engine version: staging at dd7768975aa480367a86d7fe7a177c12a7382c68
  • Install type: source worktree
  • OS + version: Windows 11, build 26200.8875
  • Browser or app shell: Not applicable; server-side persistence and filesystem paths

Logs, screenshots, or video

No UI evidence. The crop-reset path is visible through normal Persona avatar replacement. The write-failure and history-reference cases were identified through source tracing and targeted lifecycle probes.

Additional context

PR #4669 made Character and Persona deletion protect shared and historical avatar references. This is a follow-up for the remaining avatar assignment, import, replacement, and Mari Images clear paths.

The failure-window reproduction requires fault injection or a concurrent record disappearance; it is not expected during every ordinary avatar update.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Xelvanis on GitHub (Aug 9, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4789 Originally assigned to: @SpicyMarinara on GitHub. <!-- task-id: persona-avatar-lifecycle --> ## Summary Persona avatar assignment and removal do not consistently treat the database reference, crop data, and local avatar file as one lifecycle. Some replacement paths retain crop data from the previous image, failures after writing a new file can leave that file unattached, and Mari Images can delete a file that Persona version history still references. ## Expected behavior - Replacing or clearing a Persona avatar resets the crop that was calculated for the previous image. - If a newly written avatar cannot be attached to its Character or Persona record, the unattached file is removed. - Deleting a Persona avatar file removes it only after no current record or Persona version-history row references it. ## Actual behavior - Direct upload, gallery, and Mari Images paths do not all reset `avatarCrop` when the underlying Persona image changes. - Direct upload, native import, and Mari Images assignment can write an avatar before the record update succeeds; some failure paths leave that file in `data/avatars`. - Mari Images clears the current Persona reference and can unlink its file without protecting the same path when it is retained by Persona history. ## Steps to reproduce 1. Create a Persona with an avatar and save a non-empty crop. 2. Replace the avatar through direct upload, a gallery image, or Mari Images. 3. Observe that affected paths can retain the crop from the previous image. 4. Trigger a storage/update failure after an avatar file is written through direct upload, native import, or Mari Images assignment. 5. Inspect `data/avatars` and observe that affected paths can leave the new file unattached. 6. With an avatar path retained by Persona version history, clear the Persona avatar through Mari Images with file deletion enabled. 7. Observe that the file can be deleted even though the history row still references it. ## Environment - Marinara Engine version: `staging` at `dd7768975aa480367a86d7fe7a177c12a7382c68` - Install type: source worktree - OS + version: Windows 11, build 26200.8875 - Browser or app shell: Not applicable; server-side persistence and filesystem paths ## Logs, screenshots, or video No UI evidence. The crop-reset path is visible through normal Persona avatar replacement. The write-failure and history-reference cases were identified through source tracing and targeted lifecycle probes. ## Additional context PR #4669 made Character and Persona deletion protect shared and historical avatar references. This is a follow-up for the remaining avatar assignment, import, replacement, and Mari Images clear paths. The failure-window reproduction requires fault injection or a concurrent record disappearance; it is not expected during every ordinary avatar update. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:51:58 +07:00
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#2637
No description provided.