Skip to content

Report a failed save instead of crashing when MediaStore rejects it - #2251

Merged
mpretty-cyro merged 1 commit into
devfrom
fix/save-attachment-insert-failure
Nov 5, 2026
Merged

mpretty-cyro merged 1 commit into
devfrom
fix/save-attachment-insert-failure

Conversation

@mpretty-cyro

Copy link
Copy Markdown
Collaborator

Contributor checklist

  • I have tested my contribution on these devices:
  • Compiled only; not exercised on a device (see Testing below)
  • My contribution is fully baked and ready to be merged as is
  • I ensure that all the open issues my contribution fixes are mentioned in the commit message of my first commit using the Fixes #1234 syntax

Description

Crash cluster: IllegalArgumentException from ContentResolver.insert in SaveAttachmentTask.createOutputUri, escaping
doInBackground, which caught only IOException. A null insert result was also dereferenced with !!.

Both now end in the existing "save failed" toast.

Testing: compiled. A MediaStore rejection wasn't reproduced.

ContentResolver.insert throws IllegalArgumentException for values
MediaStore won't accept, and can return null; SaveAttachmentTask caught
only IOException and dereferenced the result with !!, so saving such an
attachment from a conversation or the media preview crashed. Both now
end in the existing "save failed" toast.

@mpretty-cyro mpretty-cyro left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mpretty-cyro
mpretty-cyro marked this pull request as ready for review November 5, 2026 03:13
@mpretty-cyro
mpretty-cyro merged commit e03b945 into dev Nov 5, 2026
8 of 10 checks passed
@mpretty-cyro
mpretty-cyro deleted the fix/save-attachment-insert-failure branch November 5, 2026 03:14
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