Skip to content

Comments

Set QueryChannels message_limit and member_limit defaults to null (server-driven)#6135

Merged
VelikovPetar merged 7 commits intodevelopfrom
feature/AND-1056_makes_messages_and_members_optional_in_query_channels
Feb 11, 2026
Merged

Set QueryChannels message_limit and member_limit defaults to null (server-driven)#6135
VelikovPetar merged 7 commits intodevelopfrom
feature/AND-1056_makes_messages_and_members_optional_in_query_channels

Conversation

@VelikovPetar
Copy link
Contributor

@VelikovPetar VelikovPetar commented Feb 9, 2026

Goal

We are setting the default message_limit and member_limit to null so 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 QueryChannels message_limit and member_limit defaults to null.

🎨 UI Changes

NA

Testing

  1. Open a channel list
  2. Observe the logs
  3. The QueryChannels request should not pass message_limit/member_limit in its body.

Summary by CodeRabbit

  • Refactor
    • Updated QueryChannelsRequest and related ViewModels to support nullable message and member limit parameters. When limits are omitted, server-side defaults are applied instead of client-side fixed defaults.
    • Adjusted ChannelListViewModelFactory and corresponding builders to align with the new optional parameter approach for improved configuration flexibility.

@VelikovPetar VelikovPetar added the pr:improvement Improvement label Feb 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled.

🎉 Great job! This PR is ready for review.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.26 MB 5.26 MB 0.00 MB 🟢
stream-chat-android-offline 5.48 MB 5.48 MB 0.00 MB 🟢
stream-chat-android-ui-components 10.63 MB 10.63 MB 0.00 MB 🟢
stream-chat-android-compose 12.85 MB 12.85 MB 0.00 MB 🟢

@VelikovPetar VelikovPetar changed the title Set QueryChannels messageLimit and memberLimit defaults to null (follow server-side config) Set QueryChannels message_limit and member_limit defaults to null (follow server-side config) Feb 9, 2026
@VelikovPetar VelikovPetar marked this pull request as ready for review February 9, 2026 09:10
@VelikovPetar VelikovPetar requested a review from a team as a code owner February 9, 2026 09:10
@coderabbitai
Copy link

coderabbitai bot commented Feb 9, 2026

Walkthrough

This PR makes message and member limits in channel list queries optional by changing their types from Int to nullable Int? across multiple modules, enabling server-side defaults when not specified.

Changes

Cohort / File(s) Summary
API Models - QueryChannelsRequest
stream-chat-android-client/api/stream-chat-android-client.api, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api/models/QueryChannelsRequest.kt, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/QueryChannelsRequest.kt
Changed messageLimit and memberLimit from non-nullable Int to nullable Int? with null defaults, enabling server-side defaults when not provided.
Compose Module - ChannelListViewModel & Factories
stream-chat-android-compose/api/stream-chat-android-compose.api, stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/viewmodel/channels/ChannelListViewModel.kt, stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/viewmodel/channels/ChannelViewModelFactory.kt
Updated constructors to accept nullable Int? limits instead of non-nullable primitives; removed hardcoded DEFAULT_MEMBER_LIMIT and DEFAULT_MESSAGE_LIMIT constants.
UI Components Module - ChannelListViewModel & Factories
stream-chat-android-ui-components/api/stream-chat-android-ui-components.api, stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/viewmodel/channels/ChannelListViewModel.kt, stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/viewmodel/channels/ChannelListViewModelFactory.kt
Made messageLimit and memberLimit nullable; updated constructor signatures and builder methods to use Int? with null defaults; added globalState: Flow<GlobalState> parameter to primary constructor.
State Module - Query Handling
stream-chat-android-state/src/main/java/io/getstream/chat/android/state/model/querychannels/pagination/internal/Mapper.kt, stream-chat-android-state/src/main/java/io/getstream/chat/android/state/plugin/listener/internal/QueryChannelsListenerState.kt, stream-chat-android-state/src/main/java/io/getstream/chat/android/state/sync/internal/SyncManager.kt
Removed obsolete mapping function; added default values (messageLimit: 10, memberLimit: 30) when limits are null; updated QueryChannelsRequest constructor call to use named arguments.
UI Common - Channel Info
stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/channel/info/ChannelInfoMemberViewController.kt, stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/feature/channel/info/ChannelInfoMemberViewControllerTest.kt
Added explicit memberLimit = 1 parameter to QueryChannelsRequest in distinct channel queries.
Client & Tests
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/ChatClient.kt, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/Mother.kt
Removed unused import from ChatClient; updated test helper function to accept nullable Int? parameters for messageLimit and memberLimit.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Suggested labels

compose, ui-components

Suggested reviewers

  • gpunto

Poem

🐰 Limits drift like morning mist,
Now optional, not set in stone,
Null whispers to the server's wisdom,
Defaults bloom where none were shown,
Flexibility hops along the way!

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely describes the primary change: making message_limit and member_limit default to null to follow server-side configuration.
Description check ✅ Passed The PR description covers Goal, Implementation, and Testing sections but lacks UI Changes details (marked N/A), contributor checklist items, and reviewer checklist items from the template.
Linked Issues check ✅ Passed The changes successfully implement the objective from AND-1056 by making message_limit and member_limit nullable (Int?) with null defaults throughout the codebase, allowing server-side defaults when not specified.
Out of Scope Changes check ✅ Passed All changes align with the stated objective of making message_limit and member_limit optional with null defaults; no unrelated modifications detected in the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/AND-1056_makes_messages_and_members_optional_in_query_channels

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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 | 🔴 Critical

Moshi 1.15.1 will serialize null fields as "member_limit": null rather than omitting them.

The PR objective requires fields to be absent from the JSON when null, but this code will include them as explicit null values. Moshi's default behavior (version 1.15.1) does not skip null fields—to achieve the intended behavior, either:

  1. Configure Moshi.Builder() with .serializeNulls(false), or
  2. Implement a custom JsonAdapter that omits null fields from the generated payload, or
  3. Confirm the server treats explicit null identically 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 10 and 30 are undocumented. Extracting them into named constants (e.g., DEFAULT_MESSAGE_LIMIT and DEFAULT_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()
 }

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
56.2% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Copy link
Contributor

@gpunto gpunto left a comment

Choose a reason for hiding this comment

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

Looks good, just a question

@VelikovPetar VelikovPetar changed the title Set QueryChannels message_limit and member_limit defaults to null (follow server-side config) Set QueryChannels message_limit and member_limit defaults to null (server-driven) Feb 10, 2026
@VelikovPetar VelikovPetar merged commit e9b8c6d into develop Feb 11, 2026
15 of 16 checks passed
@VelikovPetar VelikovPetar deleted the feature/AND-1056_makes_messages_and_members_optional_in_query_channels branch February 11, 2026 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:improvement Improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants