Skip to content

Migrate poll write request bodies to generated models - #6607

Merged
gpunto merged 3 commits into
developfrom
migrate/poll-write-requests
Aug 3, 2026
Merged

Migrate poll write request bodies to generated models#6607
gpunto merged 3 commits into
developfrom
migrate/poll-write-requests

Conversation

@gpunto

@gpunto gpunto commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Goal

Migrate the poll write request bodies (createPoll, updatePoll, createPollOption, updatePollOption) to the generated CreatePollRequest, UpdatePollRequest, CreatePollOptionRequest, UpdatePollOptionRequest, PollOptionInput, and PollOptionRequest network models. Unblocked by the CHA-4436 backend fix that tags the poll request custom field.

Part of AND-1291

Implementation

  • Add the 6 generated internal poll write-request models; remove the hand-written CreatePollRequest/UpdatePollRequest/UpstreamOptionDto.
  • Each model carries custom (extraData) flattened to the JSON root via a CustomObjectDtoAdapter(extraDataPropertyName = "custom") registered in MoshiChatParser; votingVisibility uses the generated sealed class + its adapter.
  • MoshiChatApi mappers and PollsApi @Body types retyped to the generated models.

Testing

  • Serialization tests (CreatePollRequestAdapterTest, PollOptionInputAdapterTest, PollWriteRequestAdapterTest) lock the flattened wire shape for all 6 models; MoshiChatApiTest covers the mappers.
  • spotlessApply, apiDump (no public-API change), detekt, and the full client testDebugUnitTest suite pass.
  • Device probe against the real backend: createPoll/updatePoll/createPollOption/updatePollOption each send custom flattened at root and voting_visibility (both anonymous and public); all return 201 and echo the custom sentinel back.

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability when creating and updating polls.
    • Preserved poll options, custom data, and voting visibility during network requests.
    • Added clearer validation when updating poll options without an ID.
    • Improved support for creating and updating poll options.
  • Tests

    • Expanded coverage for poll creation, updates, option management, custom data, and voting visibility serialization.

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

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

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

@gpunto
gpunto force-pushed the migrate/poll-write-requests branch from 8a3d46f to f5fb3b4 Compare August 3, 2026 08:44
@gpunto
gpunto marked this pull request as ready for review August 3, 2026 09:13
@gpunto
gpunto requested a review from a team as a code owner August 3, 2026 09:13
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1d5afc4b-cc73-4e54-9316-e61fd33c1a53

📥 Commits

Reviewing files that changed from the base of the PR and between f5fb3b4 and 020cd95.

📒 Files selected for processing (2)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/MoshiChatApi.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt
🚧 Files skipped from review as they are similar to previous changes (1)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/MoshiChatApi.kt

Walkthrough

Poll creation, update, and option requests now use network DTOs. Moshi adapters serialize flattened custom data and voting visibility values. API mappings reject poll updates without option IDs.

Changes

Poll DTO migration

Layer / File(s) Summary
Network poll request contracts
stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/*Poll*.kt, stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/PollOption*.kt
Added network models for poll creation, updates, and option requests. Added voting visibility handling.
Poll API mapping and serialization
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/PollsApi.kt, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/*
Updated API signatures and mappings to use network DTOs. Registered adapters for poll requests and options. Flattened custom data during serialization.
Poll request 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 tests and added serialization coverage for poll requests with and without custom data. Added failure tests for missing option IDs.

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

Possibly related PRs

Suggested labels: released

Suggested reviewers: andremion, velikovpetar

Poem

A rabbit maps each poll with care,
New DTOs carry fields through air.
Moshi folds custom data in,
Missing IDs cannot begin.
Tests keep every request fair.

🚥 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 and concisely describes migrating poll write request bodies to generated models.
Description check ✅ Passed The description covers the goal, implementation, and testing, while correctly omitting UI details for this non-UI change.
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/poll-write-requests

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: 1

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

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

Document or remove the file suppressions.

These blanket suppressions disable diagnostics in every new DTO without an explanation. Remove entries that generated code does not require. If the generator requires an entry, document that reason next to the suppression.

  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/CreatePollOptionRequest.kt#L17-L22: Narrow or document the suppressions.
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/CreatePollRequest.kt#L17-L22: Narrow or document the suppressions.
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/PollOptionInput.kt#L17-L22: Narrow or document the suppressions.
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/PollOptionRequest.kt#L17-L22: Narrow or document the suppressions.
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UpdatePollOptionRequest.kt#L17-L22: Narrow or document the suppressions.
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UpdatePollRequest.kt#L17-L22: Narrow 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/CreatePollOptionRequest.kt`
around lines 17 - 22, Remove unnecessary entries from the file-level suppression
block in each DTO, retaining only suppressions required by the generated models.
For any retained suppression, add a concise adjacent comment documenting the
generator requirement. Apply this to CreatePollOptionRequest.kt,
CreatePollRequest.kt, PollOptionInput.kt, PollOptionRequest.kt,
UpdatePollOptionRequest.kt, and UpdatePollRequest.kt at the listed suppression
blocks.

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/client/api2/MoshiChatApi.kt`:
- Around line 1837-1844: Remove the id.orEmpty() fallback in updatePollOption
and the option mapping within updatePoll; require option.id/it.id to be present
and fail fast when it is null before constructing UpdatePollOptionRequest or the
update payload. Preserve the existing mapping for valid IDs while ensuring
missing IDs are not sent as empty strings.

---

Nitpick comments:
In
`@stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/CreatePollOptionRequest.kt`:
- Around line 17-22: Remove unnecessary entries from the file-level suppression
block in each DTO, retaining only suppressions required by the generated models.
For any retained suppression, add a concise adjacent comment documenting the
generator requirement. Apply this to CreatePollOptionRequest.kt,
CreatePollRequest.kt, PollOptionInput.kt, PollOptionRequest.kt,
UpdatePollOptionRequest.kt, and UpdatePollRequest.kt at the listed suppression
blocks.
🪄 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: 0d82c020-9b3a-4052-9f6e-48fcb88f162a

📥 Commits

Reviewing files that changed from the base of the PR and between 8aa103b and f5fb3b4.

📒 Files selected for processing (15)
  • 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/PollsApi.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/PollRequests.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/MoshiChatParser.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/adapters/PollDtoAdapters.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/CreatePollOptionRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/CreatePollRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/PollOptionInput.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/PollOptionRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UpdatePollOptionRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UpdatePollRequest.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/PollOptionInputAdapterTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/PollWriteRequestAdapterTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/testdata/PollDtoTestData.kt
💤 Files with no reviewable changes (1)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/PollRequests.kt

@aleksandar-apostolov aleksandar-apostolov 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

@gpunto

gpunto commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@sonarqubecloud

sonarqubecloud Bot commented Aug 3, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
66.3% Coverage on New Code (required ≥ 80%)
8.1% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@gpunto
gpunto enabled auto-merge August 3, 2026 11:09
@gpunto
gpunto added this pull request to the merge queue Aug 3, 2026
Merged via the queue into develop with commit e464369 Aug 3, 2026
19 of 20 checks passed
@gpunto
gpunto deleted the migrate/poll-write-requests branch August 3, 2026 12:13
@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