Skip to content

Migrate queryThreads, queryReminders, queryDrafts, and partial-update-thread request bodies to generated models - #6600

Merged
gpunto merged 4 commits into
developfrom
migrate/query-payload
Jul 31, 2026
Merged

Migrate queryThreads, queryReminders, queryDrafts, and partial-update-thread request bodies to generated models#6600
gpunto merged 4 commits into
developfrom
migrate/query-payload

Conversation

@gpunto

@gpunto gpunto commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Goal

Migrate the queryThreads, queryReminders, and queryDrafts request bodies (POST /threads, POST /reminders/query, POST /drafts/query) to the generated QueryThreadsRequest / QueryRemindersRequest / QueryDraftsRequest network models. Completes the query-payload request-body cluster. Part of the incremental OpenAPI model migration.

Part of AND-1291

Implementation

  • Add the three generated internal request models in network.models; remove the hand-written api2.model.requests versions. MoshiChatApi/ThreadsApi/RemindersApi/MessageApi/tests use the generated types by their real names.
  • Each sort field is now List<SortParamRequest> (was List<Map<String, Any>>), so the call sites switch from sort.toDto() to sort.toSortParams(). filter?.toMap() fits the generated Map<String, Any?> field. queryThreads' call site switches its named args to the generated camelCase params (memberLimit/participantLimit/replyLimit). No wire-shape change.

Testing

  • spotlessCheck, apiCheck (no API drift), detekt, and the full client testDebugUnitTest suite pass.
  • Verified on device against the real backend, all three endpoints with a created_at desc sort: POST /threads, POST /reminders/query, and POST /drafts/query each send "sort":[{"direction":-1,"field":"created_at"}] and return 201. queryThreads also correctly serializes member_limit/participant_limit/reply_limit/watch.

Also folds in the partialUpdateThread request-body migration (PATCH /threads/{id} → generated UpdateThreadPartialRequest) — bundled here to keep the thread-request migrations together.

Summary by CodeRabbit

  • Bug Fixes

    • Improved request handling for draft, reminder, and thread queries.
    • Ensured sorting and partial thread updates are serialized consistently.
    • Preserved correct behavior for default and optional query parameters.
  • Tests

    • Added coverage for complete and default request payloads.
    • Verified serialized query and thread-update data against expected JSON.

@gpunto gpunto added the pr:internal Internal changes / housekeeping label Jul 29, 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 29, 2026

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.96 MB 5.96 MB -0.00 MB 🚀
stream-chat-android-ui-components 11.22 MB 11.22 MB -0.00 MB 🚀
stream-chat-android-compose 12.71 MB 12.71 MB 0.00 MB 🟢

@gpunto
gpunto force-pushed the migrate/query-payload branch from 9f53138 to 55e2e6d Compare July 30, 2026 10:35
@gpunto
gpunto force-pushed the migrate/query-payload branch from 8884b63 to 77a5e3a Compare July 31, 2026 08:58
@gpunto
gpunto marked this pull request as ready for review July 31, 2026 09:06
@gpunto
gpunto requested a review from a team as a code owner July 31, 2026 09:06
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The change moves draft, reminder, thread query, and thread partial-update requests to shared network models. API wiring now uses the new models and toSortParams(). Tests verify API payload construction and Moshi serialization.

Changes

Network request model migration

Layer / File(s) Summary
Shared request model contracts
stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/*Request.kt
Added network-layer models for draft, reminder, and thread queries. Replaced the thread partial-update model with UpdateThreadPartialRequest and explicit JSON mappings.
API request wiring
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/*.kt
Updated endpoint types and MoshiChatApi construction paths to use network models. Draft and reminder sorting now uses toSortParams().
Payload and API validation
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/parser2/*
Updated API assertions and added complete and default-field Moshi serialization fixtures for all migrated request models.

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

Possibly related PRs

Suggested reviewers: andremion, velikovpetar

Poem

A rabbit hops through models bright,
Drafts and threads now serialize right.
Sorts find their network track,
Old request shells fade back.
Tests guard each payload tight.

🚥 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
Title check ✅ Passed The title clearly summarizes the migration of query and partial-update request bodies to generated models.
Description check ✅ Passed The description covers the goal, implementation, testing, issue link, wire-shape expectations, and non-UI scope adequately.
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.
✨ 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/query-payload

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.

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

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

Document or remove the file-level suppressions.

The shared model template suppresses UnusedImport and RemoveRedundantQualifierName while each file contains unused List and Map imports and fully qualified collection types. Remove the unused imports and redundant qualifiers. If code generation requires these suppressions, document that requirement and retain only the required suppression keys.

  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/QueryDraftsRequest.kt#L17-L22: Remove or document the suppressions.
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/QueryRemindersRequest.kt#L17-L22: Remove or document the suppressions.
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/QueryThreadsRequest.kt#L17-L22: Remove or document the suppressions.
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UpdateThreadPartialRequest.kt#L17-L22: Remove or document the suppressions.

As per coding guidelines, “avoid suppressions 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/QueryDraftsRequest.kt`
around lines 17 - 22, Remove the unnecessary file-level suppressions and clean
up unused List/Map imports and fully qualified collection types in
QueryDraftsRequest.kt (lines 17-22), QueryRemindersRequest.kt (lines 17-22),
QueryThreadsRequest.kt (lines 17-22), and UpdateThreadPartialRequest.kt (lines
17-22). If the model generator requires any suppression, document that
requirement and retain only the specifically required keys.

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.

Nitpick comments:
In
`@stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/QueryDraftsRequest.kt`:
- Around line 17-22: Remove the unnecessary file-level suppressions and clean up
unused List/Map imports and fully qualified collection types in
QueryDraftsRequest.kt (lines 17-22), QueryRemindersRequest.kt (lines 17-22),
QueryThreadsRequest.kt (lines 17-22), and UpdateThreadPartialRequest.kt (lines
17-22). If the model generator requires any suppression, document that
requirement and retain only the specifically required keys.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f5e8d055-0f30-4328-b80a-c36432c2e913

📥 Commits

Reviewing files that changed from the base of the PR and between f0a5137 and 77a5e3a.

📒 Files selected for processing (14)
  • 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/MessageApi.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/endpoint/RemindersApi.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/endpoint/ThreadsApi.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/QueryDraftsRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/QueryRemindersRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/QueryThreadsRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/QueryDraftsRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/QueryRemindersRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/QueryThreadsRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UpdateThreadPartialRequest.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/parser2/QueryPayloadRequestAdapterTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/testdata/QueryPayloadRequestTestData.kt
💤 Files with no reviewable changes (3)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/QueryDraftsRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/QueryThreadsRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/QueryRemindersRequest.kt

@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.

LGTM. Three notes, none blocking.

@gpunto
gpunto enabled auto-merge July 31, 2026 14:59
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
5.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@gpunto
gpunto added this pull request to the merge queue Jul 31, 2026
Merged via the queue into develop with commit 261ad27 Jul 31, 2026
18 of 19 checks passed
@gpunto
gpunto deleted the migrate/query-payload branch July 31, 2026 16:27
@stream-public-bot stream-public-bot added the released Included in a release label Aug 13, 2026
@stream-public-bot

Copy link
Copy Markdown
Contributor

🚀 Available in v7.8.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