Set QueryChannels message_limit and member_limit defaults to null (server-driven)#6135
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
QueryChannels messageLimit and memberLimit defaults to null (follow server-side config)QueryChannels message_limit and member_limit defaults to null (follow server-side config)
WalkthroughThis PR makes message and member limits in channel list queries optional by changing their types from Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/QueryChannelsRequest.kt (1)
21-32:⚠️ Potential issue | 🔴 CriticalMoshi 1.15.1 will serialize
nullfields as"member_limit": nullrather than omitting them.The PR objective requires fields to be absent from the JSON when null, but this code will include them as explicit
nullvalues. Moshi's default behavior (version 1.15.1) does not skip null fields—to achieve the intended behavior, either:
- Configure
Moshi.Builder()with.serializeNulls(false), or- Implement a custom
JsonAdapterthat omits null fields from the generated payload, or- Confirm the server treats explicit
nullidentically to absent fields.Verify which approach is intended and implement accordingly.
🤖 Fix all issues with AI agents
In
`@stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api/models/QueryChannelsRequest.kt`:
- Around line 39-40: Document the breaking binary-compat change where
QueryChannelsRequest.messageLimit and QueryChannelsRequest.memberLimit are now
nullable Integer types: add a breaking-change entry in CHANGELOG.md prefixed
with "🚨" that states Java callers will now receive boxed Integer (may NPE if
unboxed) and reference the fix; also add an entry in DEPRECATIONS.md that
includes a migration note instructing users to handle nulls (or rely on
server-side defaults) and point to the updated KDoc in QueryChannelsRequest for
behavior when these fields are null.
In
`@stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/viewmodel/channels/ChannelListViewModelFactory.kt`:
- Around line 36-37: The KDoc param order for ChannelListViewModelFactory is out
of sync with the constructor: swap the two `@param` entries so they match the
constructor parameter order (messageLimit then memberLimit) in the KDoc for the
ChannelListViewModelFactory class/constructor to avoid confusion when reading
the docs.
🧹 Nitpick comments (1)
stream-chat-android-state/src/main/java/io/getstream/chat/android/state/plugin/listener/internal/QueryChannelsListenerState.kt (1)
71-72: Consider extracting magic numbers into named constants.The fallback values
10and30are undocumented. Extracting them into named constants (e.g.,DEFAULT_MESSAGE_LIMITandDEFAULT_MEMBER_LIMIT) with a brief comment explaining they mirror the current server-side defaults would improve readability and make future updates easier to spot.♻️ Suggested refactor
private companion object { + private const val DEFAULT_MESSAGE_LIMIT = 10 + private const val DEFAULT_MEMBER_LIMIT = 30 private fun QueryChannelsRequest.toPagination(): AnyChannelPaginationRequest = QueryChannelsPaginationRequest( sort = querySort, channelLimit = limit, channelOffset = offset, - messageLimit = messageLimit ?: 10, - memberLimit = memberLimit ?: 30, + messageLimit = messageLimit ?: DEFAULT_MESSAGE_LIMIT, + memberLimit = memberLimit ?: DEFAULT_MEMBER_LIMIT, ).toAnyChannelPaginationRequest() }
...oid-client/src/main/java/io/getstream/chat/android/client/api/models/QueryChannelsRequest.kt
Show resolved
Hide resolved
...c/main/kotlin/io/getstream/chat/android/ui/viewmodel/channels/ChannelListViewModelFactory.kt
Show resolved
Hide resolved
…rs_optional_in_query_channels
|
gpunto
left a comment
There was a problem hiding this comment.
Looks good, just a question
...oid-client/src/main/java/io/getstream/chat/android/client/api/models/QueryChannelsRequest.kt
Show resolved
Hide resolved
QueryChannels message_limit and member_limit defaults to null (follow server-side config)QueryChannels message_limit and member_limit defaults to null (server-driven)


Goal
We are setting the default
message_limitandmember_limittonullso that the request follows (a potentially dynamic) server-side default.Note: This only affects the defaults - if a customer overrides them, this change has no effect.
Note: See related discussion linked in the ticket.
Implementation
Change the
QueryChannelsmessage_limitandmember_limitdefaults tonull.🎨 UI Changes
NA
Testing
QueryChannelsrequest should not passmessage_limit/member_limitin its body.Summary by CodeRabbit