Skip to content

Abort image upload when signed-IDs fetch fails#72

Open
zew-rgn wants to merge 1 commit into
masterfrom
zew/fix-image-upload-empty-list-guard
Open

Abort image upload when signed-IDs fetch fails#72
zew-rgn wants to merge 1 commit into
masterfrom
zew/fix-image-upload-empty-list-guard

Conversation

@zew-rgn
Copy link
Copy Markdown
Collaborator

@zew-rgn zew-rgn commented Apr 15, 2026

Summary

  • Fixes a bug where failing to fetch existing signed IDs caused the backend to purge every existing image on the device.
  • fetchCurrentSignedIds silently returned [] on any failure (timeout, network, HTTP error, parse error). On slow sites this caused the upload to PUT images: [newBase64] with no existing signed IDs. The backend treats has_many_attached :images assignment as a full replacement and purged every existing attachment.
  • Adds fetchCurrentSignedIdsStrict + ImageFetchException. The upload call-site now aborts with a user-facing error instead of proceeding with an empty list. Mirrors the parallel fix in ATT-FE-Tool.

Test plan

  • Upload a photo to an AP/ONT on a slow site and verify existing photos are preserved.
  • Simulate a fetch failure (airplane mode mid-upload) and verify the user sees "Couldn't sync existing photos. Please check your connection and try again." and no photos are deleted.
  • Upload a photo to a device with no existing images (first upload) and verify it succeeds.

🤖 Generated with Claude Code

Previously fetchCurrentSignedIds silently returned [] on any failure
(timeout, network, HTTP error, parse error). On slow sites, this caused
the upload to PUT images: [newBase64] with no existing signed IDs. The
backend treats has_many_attached assignment as a full replacement and
purged every existing attachment.

Adds fetchCurrentSignedIdsStrict + ImageFetchException. The upload
call-site now aborts with a user-facing error instead of proceeding
with an empty list. Mirrors the fix in ATT-FE-Tool.
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