Fall back to AppleScript when a Private API attachment send fails (fixes silent attachment drop on macOS Tahoe) - #237
Open
Austin519 wants to merge 1 commit into
Conversation
On macOS Tahoe (26.x) the BlueBubbles Private API helper throws
NSInvalidArgumentException when sending an attachment, so photos/files sent
from Matrix are silently dropped while text still works (text uses a different
endpoint). The helper returns a non-2xx body rather than a transport error, so
apiPostAsFormData reports success with an empty GUID and the drop goes
unnoticed.
SendFile now detects a failed Private API attachment send (non-2xx status or
empty GUID) and retries via AppleScript. The AppleScript path can't target the
"any" pseudo-service that portal GUIDs use ("Can't make any into type
constant"), so resolve it to a concrete service first (ResolveIdentifier for
DMs, iMessage for groups / on lookup failure). Non-private-api sends still
deliver the caption as a follow-up message.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On macOS Tahoe (26.x), sending an attachment from Matrix to iMessage via the BlueBubbles backend fails silently. Text messages and links still deliver (they use
/api/v1/message/text), but photos/files never arrive.The BlueBubbles Private API helper throws
NSInvalidArgumentExceptionon the attachment send. BlueBubbles returns it as an HTTP 500 body:Because
apiPostAsFormData/apiRequestunmarshal the response body regardless of HTTP status and returnnil,SendFiletreats this as success with an empty GUID — so the message checkpoint is reportedSUCCESSand the dropped attachment is invisible to the user.Fix
SendFilenow:private-apiwhen it's enabled).status, or an empty returned GUID) and falls back to AppleScript.anypseudo-service before the AppleScript send. AppleScript can't targetany(set targetService to 1st account whose service type = any→Can't make any into type constant. (-1700)), so DMs are resolved to their real service viaResolveIdentifier(iMessage vs SMS), and groups / lookup failures default toiMessage.This is non-regressing: on platforms where the Private API attachment path works, nothing changes — the fallback only runs when the Private API send actually fails.
Testing
Verified on a live macOS Tahoe (26.5) + BlueBubbles 1.9.9 setup: Private API attachment sends return
[500] NSInvalidArgumentException; an AppleScript attachment send with the resolved concrete-service GUID delivers (Delivered message from [You]; Attachments: 1), whileany;-;…errors with-1700. Builds with./build.sh(libheif tag).