Skip to content

Migrate user groups to generated models - #6595

Merged
gpunto merged 6 commits into
developfrom
migrate/user-groups
Jul 29, 2026
Merged

Migrate user groups to generated models#6595
gpunto merged 6 commits into
developfrom
migrate/user-groups

Conversation

@gpunto

@gpunto gpunto commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Goal

Migrate the whole user-groups surface (/usergroups CRUD + members) to generated network.models. First slice vendored from the current /chat master generator, and the first response-side migration. Unblocked by the upstream fix for the same-name struct collapse (#12/#15/#16): UserGroupResponse now carries members and no longer needs the local rename patch. Part of the incremental OpenAPI model migration.

Part of AND-1291

Implementation

  • Vendor 13 generated internal models: the 4 request bodies (Create/Update/AddUserGroupMembers/RemoveUserGroupMembers), the 7 per-endpoint response wrappers (Create/Get/Update/Add/RemoveUserGroupMembersResponse, ListUserGroupsResponse, SearchUserGroupsResponse), plus the shared UserGroupResponse object and UserGroupMember.
  • UserGroupApi returns the generated per-endpoint wrappers; request @Body types use the generated requests. MoshiChatApi call sites pass camelCase args and map via generic helpers mapUserGroup { it.userGroup } / mapUserGroups { it.userGroups }. DomainMapping gains UserGroupResponse.toDomain() + UserGroupMember.toDomain().
  • Remove the hand-written UserGroupRequests.kt and UserGroupResponses.kt. Keep UserGroupDtos.kt (DownstreamUserGroupDto) — still used by Message.mentioned_groups, which is part of the deferred message migration.
  • Tests: add Mother.randomUserGroupResponse() + one arg provider per endpoint; retype the 8 user-group test functions.

Testing

  • apiCheck (no API drift — all internal), detekt, spotlessCheck, and the full client testDebugUnitTest suite pass.
  • Verified on device against the real backend, full CRUD cycle: create -> get -> update -> add members -> remove members -> query -> search -> delete. Every per-endpoint response wrapper (and the nested UserGroupResponse object + members) parsed cleanly (no JsonDataException); request bodies serialize the expected member_ids/name/id shapes.

Summary by CodeRabbit

Release Notes

  • Chores
    • Reorganized internal API models for user group operations to improve data handling and consistency. User group management functionality remains unchanged.

@gpunto gpunto added the pr:internal Internal changes / housekeeping label Jul 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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, or the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.95 MB 5.96 MB 0.01 MB 🟢
stream-chat-android-ui-components 11.22 MB 11.23 MB 0.01 MB 🟢
stream-chat-android-compose 12.70 MB 12.70 MB 0.01 MB 🟢

@gpunto
gpunto force-pushed the migrate/user-groups branch from 78136d5 to 089ceea Compare July 28, 2026 15:51
@gpunto
gpunto force-pushed the migrate/user-groups branch from 089ceea to a7e5361 Compare July 28, 2026 16:03
@gpunto
gpunto marked this pull request as ready for review July 29, 2026 06:38
@gpunto
gpunto requested a review from a team as a code owner July 29, 2026 06:38
@gpunto
gpunto enabled auto-merge (squash) July 29, 2026 06:38
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

User-group API operations now use dedicated network request/response models, extractor-based response mapping, domain conversions, and updated API2 contract tests.

Changes

User-group model migration

Layer / File(s) Summary
Network contracts and DTOs
stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/*, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/endpoint/UserGroupApi.kt
Adds Moshi-backed request, response, group, and member models and updates endpoint return types to endpoint-specific wrappers.
API request and domain mapping
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/MoshiChatApi.kt, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/DomainMapping.kt
Builds camelCase request models, extracts wrapped payloads through generic mapping helpers, and converts groups and members into domain objects.
API2 contract test updates
stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/*, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/Mother.kt
Updates fixtures, response providers, request properties, and parameterized tests for the new network models.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested labels: QAed

Suggested reviewers: andremion, aleksandar-apostolov, kanat

Poem

A rabbit hops through models bright,
With camelCase tucked snug and right.
Groups unwrap, then domains grow,
Tests chase each response flow.
“Moshi magic!” the bunny sings,
While fresh DTOs sprout their wings.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: migrating user groups to generated models.
Description check ✅ Passed The description covers Goal, Implementation, and Testing; only non-critical template sections like UI, checklists, and GIF are missing.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch migrate/user-groups

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/AddUserGroupMembersRequest.kt (1)

17-22: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Narrow or document the repeated file-level suppressions.

The same blanket suppression set is repeated across the generated models without explaining which rules are required. Remove unnecessary suppressions per file, or document the generator-level rationale and retain only the minimal set.

  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/AddUserGroupMembersRequest.kt#L17-L22: narrow or document the suppression block.
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/CreateUserGroupRequest.kt#L17-L22: narrow or document the suppression block.
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UpdateUserGroupRequest.kt#L17-L22: narrow or document the suppression block.
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/RemoveUserGroupMembersRequest.kt#L17-L22: narrow or document the suppression block.
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UserGroupMember.kt#L17-L22: narrow or document the suppression block.
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UserGroupResponse.kt#L17-L22: narrow or document the suppression block.
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/AddUserGroupMembersResponse.kt#L17-L22: narrow or document the suppression block.
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/CreateUserGroupResponse.kt#L17-L22: narrow or document the suppression block.
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/GetUserGroupResponse.kt#L17-L22: narrow or document the suppression block.

As per coding guidelines, suppressions should be avoided unless documented.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/AddUserGroupMembersRequest.kt`
around lines 17 - 22, The repeated blanket file-level suppressions are
undocumented and may include unnecessary rules. In
AddUserGroupMembersRequest.kt, CreateUserGroupRequest.kt,
UpdateUserGroupRequest.kt, RemoveUserGroupMembersRequest.kt, UserGroupMember.kt,
UserGroupResponse.kt, AddUserGroupMembersResponse.kt,
CreateUserGroupResponse.kt, and GetUserGroupResponse.kt, remove suppressions
that are not required; retain only the minimal necessary rules and document the
generator-level rationale when shared suppressions must remain.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/ListUserGroupsResponse.kt`:
- Around line 17-22: Document the rationale for each required entry in the
file-wide suppression block, or remove entries that are unnecessary, in
ListUserGroupsResponse.kt lines 17-22, RemoveUserGroupMembersResponse.kt lines
17-22, SearchUserGroupsResponse.kt lines 17-22, and UpdateUserGroupResponse.kt
lines 17-22. Keep only suppressions required by the generated response model
declarations and ensure each retained suppression has a clear explanation.

In
`@stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt`:
- Line 3157: Rename the tests in
stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt
at lines 3157, 3189, 3223, 3258, 3273, 3313, and 3338—testCreateUserGroup,
testListUserGroups, testSearchUserGroups, testGetUserGroup, testUpdateUserGroup,
testAddUserGroupMembers, and testRemoveUserGroupMembers—to readable Kotlin
backtick test names while preserving their existing behavior.

---

Nitpick comments:
In
`@stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/AddUserGroupMembersRequest.kt`:
- Around line 17-22: The repeated blanket file-level suppressions are
undocumented and may include unnecessary rules. In
AddUserGroupMembersRequest.kt, CreateUserGroupRequest.kt,
UpdateUserGroupRequest.kt, RemoveUserGroupMembersRequest.kt, UserGroupMember.kt,
UserGroupResponse.kt, AddUserGroupMembersResponse.kt,
CreateUserGroupResponse.kt, and GetUserGroupResponse.kt, remove suppressions
that are not required; retain only the minimal necessary rules and document the
generator-level rationale when shared suppressions must remain.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cb1d0f5c-99c2-4c2d-9bec-c20230810997

📥 Commits

Reviewing files that changed from the base of the PR and between 610f17b and 476daae.

📒 Files selected for processing (20)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/MoshiChatApi.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/endpoint/UserGroupApi.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/DomainMapping.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/UserGroupRequests.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/AddUserGroupMembersRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/AddUserGroupMembersResponse.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/CreateUserGroupRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/CreateUserGroupResponse.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/GetUserGroupResponse.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/ListUserGroupsResponse.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/RemoveUserGroupMembersRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/RemoveUserGroupMembersResponse.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/SearchUserGroupsResponse.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UpdateUserGroupRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UpdateUserGroupResponse.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UserGroupMember.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UserGroupResponse.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/Mother.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTestArguments.kt
💤 Files with no reviewable changes (1)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/UserGroupRequests.kt

@gpunto
gpunto disabled auto-merge July 29, 2026 07:41

@andremion andremion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice cleanup! Left a question about the failure mode of mapUserGroup and a note on test coverage.

@gpunto
gpunto enabled auto-merge July 29, 2026 09:10
@gpunto
gpunto disabled auto-merge July 29, 2026 09:11
@gpunto
gpunto enabled auto-merge July 29, 2026 09:11
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

@gpunto
gpunto added this pull request to the merge queue Jul 29, 2026
Merged via the queue into develop with commit c92c5d2 Jul 29, 2026
18 of 19 checks passed
@gpunto
gpunto deleted the migrate/user-groups branch July 29, 2026 10:55
@stream-public-bot stream-public-bot added the released Included in a release label Jul 30, 2026
@stream-public-bot

Copy link
Copy Markdown
Contributor

🚀 Available in v7.7.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:internal Internal changes / housekeeping released Included in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants