-
Notifications
You must be signed in to change notification settings - Fork 21
D14z client prerelease updates #493
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
base: main
Are you sure you want to change the base?
Conversation
This reverts commit 37958fb.
How to use the Graphite Merge QueueAdd the label mergequeue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
|
Claude finished @cameronvoell's task —— View job Code Review Complete ✅Reviewed PR #493: D14z client prerelease updates SummaryThis PR updates the SDK to use the latest libxmtp version (c0462383b on d14z-client-prerelease branch) and adds test coverage for the d14n staging environment. The changes include API client caching improvements, the addition of Detailed Findings✅ Positive Aspects
🔍 Code Quality IssuesClient.kt (library/src/main/java/org/xmtp/android/library/Client.kt)
Dm.kt (library/src/main/java/org/xmtp/android/library/Dm.kt)
Group.kt (library/src/main/java/org/xmtp/android/library/Group.kt)
SendOptions.kt (library/src/main/java/org/xmtp/android/library/SendOptions.kt)
ClientTest.kt (library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt)
|
Add gatewayUrl-based backend client selection and caching and propagate
MessageVisibilityOptionsthroughConversation,Dm, andGroupsend/prepare flows in Client.kt and messaging classes to support D14z client prerelease updatesThis pull request introduces gateway-aware backend client caching and extends messaging methods to carry message visibility options through to the FFI layer. It adds a
gatewayUrlfield toClientOptions, replaces cache keys with a configuration-derived key including environment URL, gateway URL,isSecure, andappVersion, and updates connection logic accordingly. It also modifiesConversation,Dm, andGroupAPIs to compute and passMessageVisibilityOptions(includingshouldPush) into send and optimistic send paths, and regenerates UniFFI bindings to accept the new FFI options. Test coverage is expanded to validate client creation and gateway usage.env.getUrl(),gatewayUrl,isSecure, andappVersion, and propagategatewayUrlinto backend connections in Client.ktMessageVisibilityOptionswithshouldPushand FFI conversion in SendOptions.kt; modifyConversation,Dm, andGroupsend/prepare signatures to accept and forward visibility options in Conversation.kt, Dm.kt, and Group.ktFfiSendMessageOptsforsendandsendOptimisticin xmtpv3.kt and update bundled native librariesgatewayUrland configuration-driven cache keys in ClientTest.ktlibxmtpversion metadata in libxmtp-version.txt📍Where to Start
Start with the backend client cache key generation in
Client.createCacheKeyand its use in connection setup in Client.kt, then review howMessageVisibilityOptionsis computed and propagated throughDm.encodeContent,Group.encodeContent, andConversation.send/preparein Dm.kt, Group.kt, and Conversation.kt.📊 Macroscope summarized c78f91f. 6 files reviewed, 12 issues evaluated, 12 issues filtered, 0 comments posted
🗂️ Filtered Issues
library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt — 0 comments posted, 2 evaluated, 2 filtered
canMessagecan be silently skipped due to the use of a safe-call on a potentially missing map entry. Inclient.canMessage(listOf(clientIdentity))[clientIdentity.identifier]?.let { assert(it) }, if the keyclientIdentity.identifieris not present in the returned map, the safe-call (?.) preventsletfrom running, and no assertion is performed. This yields a false positive test pass while the core condition (that the identity is present and can be messaged) remains unverified. Replace with an explicit presence check and value assertion (e.g.,assertTrue(client.canMessage(listOf(clientIdentity))[clientIdentity.identifier] == true)orassertTrue(requireNotNull(client.canMessage(...)[clientIdentity.identifier]))). [ Test / Mock code ]canMessageis vulnerable to being skipped for missing keys due to?.let. Inclient.canMessage(listOf(clientIdentity))[clientIdentity.identifier]?.let { assert(it) }, if the identity is absent from the result map, theletblock will not run and no assertion is made, allowing the test to pass without proving the expected behavior (that the client can message the identity). Use an explicit assertion that both the key exists and the value is true (e.g.,assertTrue(client.canMessage(listOf(clientIdentity))[clientIdentity.identifier] == true)orassertTrue(requireNotNull(client.canMessage(...)[clientIdentity.identifier]))). [ Test / Mock code ]library/src/main/java/org/xmtp/android/library/Client.kt — 0 comments posted, 2 evaluated, 2 filtered
createCacheKey()uses a simple pipe|delimiter between fields without escaping values. If any field value itself contains|(e.g., a malformed or customgatewayUrlor anappVersionstring), different tuples of values can produce identical concatenated strings, creating cache key collisions and leading to incorrect reuse ofXmtpApiClientinstances. Use an encoding that escapes delimiters, or a structured key (e.g., JSON with escaping, map-based key, or length-prefixed fields) to ensure uniqueness. [ Low confidence ]createCacheKey()encodes nullable values by substituting the literal string"null"forgatewayUrlandappVersion. This can collide with legitimate inputs where a caller passes the literal value"null"for either field, causing different API configurations to map to the same cache key and potentially reuse a wrongXmtpApiClientinstance. To avoid collisions, encode optionals in a way that cannot be produced by a legitimate value (e.g., prefixing with a marker or using structured encoding/escaping). [ Low confidence ]library/src/main/java/org/xmtp/android/library/Conversation.kt — 0 comments posted, 2 evaluated, 2 filtered
optstoMessageVisibilityOptions(shouldPush = true)inConversation.prepareMessage(encodedContent, opts)can cause messages to be pushed even when the associated codec's policy would prefer not to. Callers using the encoded-content overload have no way to inherit codec-derived visibility and may unintentionally publish messages. This is a behavior regression introduced by addingoptswith a default true value. [ Low confidence ]optstoMessageVisibilityOptions(shouldPush = true)inConversation.send(encodedContent, opts)can result in always pushing messages for callers who supply pre-encoded content, regardless of codec policy. Other overloads deriveshouldPushfrom the codec viaencodeContent, causing inconsistency and potential unintended publication. [ Low confidence ]library/src/main/java/org/xmtp/android/library/Dm.kt — 0 comments posted, 3 evaluated, 3 filtered
Dm.send(encodedContent, opts)defaultsoptstoMessageVisibilityOptions(shouldPush = true), which may publish messages even when a codec would have suggestedshouldPush = false. This makes the encoded-content path behavior diverge fromsend<T>andsend(text), which deriveshouldPushfrom the codec. [ Low confidence ]Dm.encodeContentcatches allExceptionand rethrowsXMTPException("Codec type is not registered"), losing the original cause and stack. This misclassifies unrelated failures (e.g., compression errors, codec runtime errors) as registration problems, hindering debugging and accurate error handling. [ Low confidence ]Dm.prepareMessage(encodedContent, opts)defaultsoptstoMessageVisibilityOptions(shouldPush = true). Even though this path is "optimistic" (not immediately publishing), the visibility option likely influences later publish behavior. Defaulting to true may be inconsistent with codec policy and other overloads that deriveshouldPushfrom codec. [ Low confidence ]library/src/main/java/org/xmtp/android/library/Group.kt — 0 comments posted, 3 evaluated, 3 filtered
Group.send(encodedContent, opts)defaultsoptstoMessageVisibilityOptions(shouldPush = true), which may publish messages for callers supplying pre-encoded content even when a codec would prefershouldPush = false. This diverges from other overloads that deriveshouldPushviaencodeContent. [ Low confidence ]Group.encodeContentcatches allExceptionand rethrowsXMTPException("Codec type is not registered"), discarding the original cause and stack trace. Non-registration errors (e.g., compression failures, codec runtime errors) are misreported and hard to diagnose. [ Low confidence ]Group.prepareMessage(encodedContent, opts)defaultsoptstoMessageVisibilityOptions(shouldPush = true), potentially marking messages for push later even when a codec would suggestshouldPush = false. This is inconsistent withprepareMessage<T>that derivesshouldPushviaencodeContent. [ Low confidence ]