Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: streamDecryptedMessages from a group not working when streaming client sends message #190

Closed
cameronvoell opened this issue Feb 28, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@cameronvoell
Copy link
Contributor

cameronvoell commented Feb 28, 2024

Describe the bug

When we call group.streamDecryptedMessages() from a group that is referenced by client alix, and then alix sends a message, that message is not streaming.

Expected behavior

Messages sent from the streaming client, and other clients should both show up when we call group.streamDecryptedMessages(). See passing xmtp-ios test here: xmtp/xmtp-ios#269

Steps to reproduce the bug

Run the new test testCanStreamDecryptedGroupMessagesFromSelf from this draft PR: #189

Issue is also re-produced in React Native SDK only on the Android Side, see https://github.com/xmtp/xmtp-react-native/pull/293/files

image
@cameronvoell cameronvoell added the bug Something isn't working label Feb 28, 2024
@cameronvoell
Copy link
Contributor Author

Not immediately obvious why android group messages arent streaming from self, group.streamDecryptedMessages() looks like a pretty straightforward call to libxmtp, so not sure why the discrepancy with xmtp-ios 🤔

fun streamDecryptedMessages(): Flow<DecryptedMessage> = callbackFlow {
val messageCallback = object : FfiMessageCallback {
override fun onMessage(message: FfiMessage) {
trySend(Message(client, message).decrypt())
}
}
val stream = libXMTPGroup.stream(messageCallback)
awaitClose { stream.end() }
}

@cameronvoell cameronvoell self-assigned this Feb 29, 2024
@cameronvoell
Copy link
Contributor Author

cameronvoell commented Mar 4, 2024

Issue was re-created in libxmtp repo, see libxmtp branch: cv/re-create-cant-stream-message-from-self

libxmtp android test app with errors:

ERROR - [libxmtp] receive error ReceiveErrors([Storage(DieselResult(DatabaseError(UniqueViolation, "UNIQUE constraint failed: group_messages.id"))), Storage(DieselResult(DatabaseError(UniqueViolation, "UNIQUE constraint failed: group_messages.id"))), Storage(DieselResult(DatabaseError(UniqueViolation, "UNIQUE constraint failed: group_messages.id"))), OpenMlsProcessMessage(ValidationError(UnableToDecrypt(GenerationOutOfBound)))])

see log below:

2024-03-04 09:53:28.779 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.782 19452-19481 App                     com.example.xmtpv3_example           I  INFO - Message callback with ID: 2ff5b9d650be18c908c1a15c939243ae54500d06fc1faeca4c9dc36b3a8a80ce, from: 0xfe78b72114757bc7a100f6cb1d8d339ff809de3a
2024-03-04 09:53:28.799 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.805 19452-19481 App                     com.example.xmtpv3_example           I  INFO - Message callback with ID: 6d9cbbdf51c18c101355cabb8610eaf5687d9a13b54b3c343b58de26da378ce1, from: 0xfe78b72114757bc7a100f6cb1d8d339ff809de3a
2024-03-04 09:53:28.822 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.827 19452-19481 App                     com.example.xmtpv3_example           I  INFO - Message callback with ID: 0ddc2d21db965a5fbe3fadba236d1da2ccc539cd6ba03183d2546cc54443cf9d, from: 0xfe78b72114757bc7a100f6cb1d8d339ff809de3a
2024-03-04 09:53:28.847 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.848 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.848 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 0
                                                                                                    	RatchetTypeError
2024-03-04 09:53:28.856 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] error publishing intents Storage(DieselResult(DatabaseError(Unknown, "database is locked")))
2024-03-04 09:53:28.862 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.863 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 0
                                                                                                    	RatchetTypeError
2024-03-04 09:53:28.864 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] receive error ReceiveErrors([Storage(DieselResult(DatabaseError(UniqueViolation, "UNIQUE constraint failed: group_messages.id"))), Storage(DieselResult(DatabaseError(UniqueViolation, "UNIQUE constraint failed: group_messages.id"))), Storage(DieselResult(DatabaseError(UniqueViolation, "UNIQUE constraint failed: group_messages.id"))), OpenMlsProcessMessage(ValidationError(UnableToDecrypt(GenerationOutOfBound)))])
2024-03-04 09:53:28.865 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] Error processing stream entry: Sync([Storage(DieselResult(DatabaseError(Unknown, "database is locked")))])
2024-03-04 09:53:28.866 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.866 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.867 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 0
                                                                                                    	RatchetTypeError
2024-03-04 09:53:28.871 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.871 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 0
                                                                                                    	RatchetTypeError
2024-03-04 09:53:28.871 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] receive error ReceiveErrors([OpenMlsProcessMessage(ValidationError(UnableToDecrypt(GenerationOutOfBound)))])
2024-03-04 09:53:28.872 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Skipped message streaming payload
2024-03-04 09:53:28.884 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.885 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.886 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 1
                                                                                                    	RatchetTypeError
2024-03-04 09:53:28.890 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] error publishing intents Storage(NotFound)
2024-03-04 09:53:28.892 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.892 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 0
                                                                                                    	RatchetTypeError
2024-03-04 09:53:28.894 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.894 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 1
                                                                                                    	RatchetTypeError
2024-03-04 09:53:28.895 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] receive error ReceiveErrors([OpenMlsProcessMessage(ValidationError(UnableToDecrypt(GenerationOutOfBound))), OpenMlsProcessMessage(ValidationError(UnableToDecrypt(GenerationOutOfBound)))])
2024-03-04 09:53:28.896 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] Error processing stream entry: Sync([Storage(NotFound)])
2024-03-04 09:53:28.896 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.897 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.897 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 1
                                                                                                    	RatchetTypeError
2024-03-04 09:53:28.900 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] receive error ReceiveErrors([Storage(DieselResult(DatabaseError(Unknown, "database is locked")))])
2024-03-04 09:53:28.900 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Skipped message streaming payload
2024-03-04 09:53:28.907 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.907 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.907 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 2
                                                                                                    	RatchetTypeError
2024-03-04 09:53:28.910 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] error publishing intents Storage(NotFound)
2024-03-04 09:53:28.912 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.912 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 1
                                                                                                    	RatchetTypeError
2024-03-04 09:53:28.914 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.914 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 2
                                                                                                    	RatchetTypeError
2024-03-04 09:53:28.914 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] receive error ReceiveErrors([OpenMlsProcessMessage(ValidationError(UnableToDecrypt(GenerationOutOfBound))), OpenMlsProcessMessage(ValidationError(UnableToDecrypt(GenerationOutOfBound)))])
2024-03-04 09:53:28.915 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] Error processing stream entry: Sync([Storage(NotFound)])
2024-03-04 09:53:28.916 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.916 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.916 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 2
                                                                                                    	RatchetTypeError
2024-03-04 09:53:28.924 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] This is the wrong ratchet type.
2024-03-04 09:53:28.924 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp]   Ciphertext generation out of bounds 2
                                                                                                    	RatchetTypeError
2024-03-04 09:53:28.924 19452-19481 Rust                    com.example.xmtpv3_example           I  ERROR - [libxmtp] receive error ReceiveErrors([OpenMlsProcessMessage(ValidationError(UnableToDecrypt(GenerationOutOfBound)))])
2024-03-04 09:53:28.924 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Skipped message streaming payload
2024-03-04 09:53:28.949 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.953 19452-19481 App                     com.example.xmtpv3_example           I  INFO - Message callback with ID: 84199ba5f36bc580357d8ea1cdc60a9c0fc0bae2b23d5235661acc341a51348d, from: 0xfe78b72114757bc7a100f6cb1d8d339ff809de3a
2024-03-04 09:53:28.965 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.972 19452-19481 App                     com.example.xmtpv3_example           I  INFO - Message callback with ID: 334ddde2d7c415f43ff5b8452fffb05d0e51be57dbdcdaf8d2e6bcb0d336b095, from: 0xfe78b72114757bc7a100f6cb1d8d339ff809de3a
2024-03-04 09:53:28.989 19452-19481 Rust                    com.example.xmtpv3_example           I  INFO - [libxmtp] Received message streaming payload
2024-03-04 09:53:28.993 19452-19481 App                     com.example.xmtpv3_example           I  INFO - Message callback with ID: f265502fadc01708599d51a57ad5874de9ce33f77e0d8d1467c86e2598ab6720, from: 0xfe78b72114757bc7a100f6cb1d8d339ff809de3a
2024-03-04 09:53:28.995 19452-19452 App                     com.example.xmtpv3_example           I  Setting up conversation streaming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants