Parse unix nanosecond dates in the generated models by gpunto · Pull Request #6807 · GetStream/stream-chat-android · GitHub
Skip to content

Parse unix nanosecond dates in the generated models - #6807

Merged
gpunto merged 4 commits into
developfrom
migrate/v2-integer-dates
Oct 13, 2026
Merged

gpunto merged 4 commits into
developfrom
migrate/v2-integer-dates

Conversation

@gpunto

@gpunto gpunto commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Goal

Let the generated models parse v2 dates, which arrive as unix nanosecond integers instead of RFC 3339 strings.

Part of AND-1637

Implementation

  • ExactDate and IsoDateAdapter are regenerated from the updated generator templates. A digits-only value is read as unix nanoseconds; strings keep the existing path.
  • ExactDate.raw holds a nanosecond date as RFC 3339 with 9 fractional digits, so it has the same format whichever API version sent it.
  • IsoDateAdapter now returns a copy of the cached Date, as the generator emits it.

No behaviour change on the current endpoints, which still send strings.

Testing

  • ExactDateParsingTest and IsoDateAdapterTest cover JSON numbers, quoted digits and zero-padded fractions.
  • V2PayloadParsingTest parses a v2 message.new frame through Serializer.moshi and checks its dates and custom data.
  • Smoke run on the compose sample (channel list, channel, send, reaction, thread reply, search, threads) with no parse errors.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved date handling for Unix nanosecond timestamps, including quoted and unquoted values. Timestamps now retain their full precision in the raw date value while mapping to the correct millisecond date.
    • Improved compatibility when parsing responses containing unrecognized enum values, helping preserve data from newer or differing server responses.

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

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 6.21 MB 6.21 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.51 MB 11.51 MB 0.00 MB 🟢
stream-chat-android-compose 13.18 MB 13.18 MB 0.00 MB 🟢

Base automatically changed from migrate/v2-serializer to develop October 12, 2026 12:12
@gpunto
gpunto marked this pull request as ready for review October 12, 2026 15:08
@gpunto
gpunto requested a review from a team as a code owner October 12, 2026 15:08
@gpunto
gpunto enabled auto-merge October 12, 2026 15:08
@coderabbitai

coderabbitai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 57c35e2d-e493-47c7-a60f-10acb1342949

📥 Commits

Reviewing files that changed from the base of the PR and between 84c9d14 and de2a05f.


📒 Files selected for processing (8)
  • 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/network/infrastructure/ExactDate.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/infrastructure/IsoDateAdapter.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/infrastructure/Serializer.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/ExactDateParsingTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/IsoDateAdapterTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/network/infrastructure/SerializerTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/network/infrastructure/V2PayloadParsingTest.kt

💤 Files with no reviewable changes (1)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/MoshiChatParser.kt

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.



📝 Walkthrough

Walkthrough

The date adapters now parse digit-only Unix-nanosecond values. ExactDate preserves nanosecond precision in its raw RFC 3339 value, while its stored instant and IsoDateAdapter dates use millisecond precision. Serializer configuration registers additional network-model adapters and the client ExactDateAdapter. Tests cover date parsing, enum handling, and message.new payload mapping.


Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to de2a0

No actionable issue is established for the date-parsing and serializer changes; the PR is mergeable after normal checks.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 7 files. 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 the primary change: parsing Unix nanosecond dates in generated models.
Description check Passed The description includes the goal, implementation details, testing coverage, issue context, and smoke-test results. The UI and checklist sections are omitted, but they are not relevant to this non-UI …
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.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

I’m a rabbit, hopping through each date,
Nine bright digits mark the fraction’s place.
I nibble JSON, both quoted and bare,
Then map a message with dates to spare.
The adapters settle, the tests all run,
I twitch my nose and call it done.

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

@sonarqubecloud

Copy link
Copy Markdown

@gpunto
gpunto added this pull request to the merge queue Oct 13, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 13, 2026
@gpunto
gpunto added this pull request to the merge queue Oct 13, 2026
Merged via the queue into develop with commit 2016eef Oct 13, 2026
19 checks passed
@gpunto
gpunto deleted the migrate/v2-integer-dates branch October 13, 2026 15:05
@stream-public-bot stream-public-bot added the released Included in a release label Oct 16, 2026
@stream-public-bot

Copy link
Copy Markdown
Contributor

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