Skip to content

Migrate file upload and message translation to generated models - #6632

Draft
gpunto wants to merge 2 commits into
developfrom
migrate/upload-translate
Draft

Migrate file upload and message translation to generated models#6632
gpunto wants to merge 2 commits into
developfrom
migrate/upload-translate

Conversation

@gpunto

@gpunto gpunto commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Goal

Migrate the file upload response and the message translation request body to the generated network models.

Part of AND-1291

Implementation

  • Add generated FileUploadResponse; remove the hand-written UploadFileResponse and rename its mapper and
    test to match. It covers all four upload endpoints (/channels/{type}/{id}/file,
    /channels/{type}/{id}/image, /uploads/file, /uploads/image).
  • The generated file is nullable, matching the wire: Go tags it omitempty, so an empty asset URL is
    omitted and the old non-null file: String would have failed to parse. A response without a URL has
    nothing to attach, so toUploadedFile() now returns a Result and reports it as a failure;
    StreamFileUploader uses flatMap to carry that through.
  • Add generated TranslateMessageRequest; remove the hand-written one. ChatClient.translate still takes
    a String, converted with Language.fromString, which falls back to Unknown and sends the value
    through unchanged, so an unsupported language is still rejected by the server rather than locally.
  • Exclude the generated network/** path from the LongMethod detekt rule: the models map each wire enum
    in one exhaustive when (57 entries for Language), which a formatter cannot split and which would be
    regenerated anyway.

Testing

  • UploadFileResponseMappingTest covers the mapping, a missing thumbnail, and the missing-URL failure.
  • TranslateMessageRequestAdapterTest asserts the serialized body for a known language, for one the models
    do not know, and for every one of the 57 languages the endpoint accepts. Removing the Language adapter
    registration makes them fail.
  • Device-probed all four upload endpoints plus translate. Every upload resolved a CDN URL, and all four
    returned no thumb_url, so the nullable thumbnail path is the normal shape rather than an edge case.
    translate sent {"language":"fr"}, unchanged from the hand-written body, and an invalid language was
    rejected by the server with its list of accepted values. That list matches the generated enum exactly,
    all 57 values.

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

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.96 MB 5.97 MB 0.01 MB 🟢
stream-chat-android-ui-components 11.26 MB 11.26 MB 0.00 MB 🟢
stream-chat-android-compose 12.74 MB 12.75 MB 0.01 MB 🟢

@gpunto
gpunto force-pushed the migrate/upload-translate branch 2 times, most recently from 9a512e9 to d6f911f Compare August 11, 2026 15:17
@gpunto
gpunto force-pushed the migrate/upload-translate branch from d6f911f to f703b0d Compare August 11, 2026 15:21
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

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

Labels

pr:internal Internal changes / housekeeping

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant