Skip to content

Fix fast event parser routing mention flags into extraData instead of typed fields#6528

Draft
gpunto wants to merge 1 commit into
developfrom
fix/fast-event-parser-mentions
Draft

Fix fast event parser routing mention flags into extraData instead of typed fields#6528
gpunto wants to merge 1 commit into
developfrom
fix/fast-event-parser-mentions

Conversation

@gpunto

@gpunto gpunto commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Goal

The opt-in fast event parser (MessageAdapter in parser2/direct, used by DirectEventParser for message.new) has no cases for the always-present mentioned_here, mentioned_channel, mentioned_groups, and mentioned_roles wire keys. They fall through to the else branch and land in Message.extraData.

Closes AND-1272

Implementation

  • Added the four missing when cases in MessageAdapter, mapping them to the same domain fields and defaults as the DTO path.
  • Added an internal UserGroupAdapter to parse mentioned_groups, wired through DirectEventParser.

Testing

  • Updated the parser parity fixtures to carry all four keys (populated, empty, and a populated mentioned_groups) so the existing DTO-path vs direct-path parity tests now exercise the fix.
  • ./gradlew :stream-chat-android-client:testDebugUnitTest passes.

Summary by CodeRabbit

  • New Features

    • Messages now support additional mention details, including channel, group, and role mentions.
    • User group information can now be parsed alongside messages.
  • Bug Fixes

    • Improved message parsing to preserve mention-related data when present or explicitly null.
    • Added support for parsing user group membership details in direct message flows.
  • Tests

    • Updated parsing test coverage and sample data to reflect the new mention and user group fields.

@gpunto gpunto added the pr:bug Bug fix label Jun 26, 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.

@gpunto gpunto force-pushed the fix/fast-event-parser-mentions branch from 4e8aa75 to ee48bf0 Compare June 26, 2026 14:26
@gpunto

gpunto commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 26, 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.

@github-actions

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.90 MB 5.90 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.15 MB 11.16 MB 0.00 MB 🟢
stream-chat-android-compose 12.63 MB 12.63 MB 0.00 MB 🟢

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Direct message parsing now includes user-group adapters and new mention metadata fields. Parser tests and fixtures were updated to construct the added adapters and cover the expanded message shape.

Changes

User-group adapters and direct wiring

Layer / File(s) Summary
User-group adapters and wiring
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/DirectEventParser.kt, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/direct/UserGroupAdapter.kt, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/direct/UserGroupMemberAdapter.kt
DirectEventParser now creates and passes user-group adapters through the direct parsing graph, and the new adapters parse UserGroup and UserGroupMember JSON in the direct-to-domain path.

Direct message mention fields

Layer / File(s) Summary
Mention fields in direct messages
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/direct/MessageAdapter.kt
MessageAdapter now reads mentioned_here, mentioned_channel, mentioned_groups, and mentioned_roles from direct message JSON and maps them onto Message fields.
Parser tests and fixtures
stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/MessageParsingTest.kt, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/NewMessageEventParsingTest.kt, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/testdata/MessageTestData.kt
Parser setup now wires the user-group adapters into direct-path tests, and message fixtures include the new mention fields in JSON and expected models.

Sequence Diagram(s)

sequenceDiagram
  participant DirectEventParser
  participant UserGroupMemberAdapter
  participant UserGroupAdapter
  participant MessageAdapter
  DirectEventParser->>UserGroupMemberAdapter: create lazy adapter
  DirectEventParser->>UserGroupAdapter: create lazy adapter with member adapter and dateAdapter
  DirectEventParser->>MessageAdapter: pass userGroupAdapter
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

pr:improvement

Suggested reviewers

  • andremion

Poem

A rabbit hopped through parser light, 🐇
գտ? No—here's a proper moonlit sight:
New groups and mentions, snug and neat,
Made direct messages hop to the beat.
Carrots approved this JSON rite.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% 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 the main change: rerouting mention-related flags from extraData into typed fields.
Description check ✅ Passed The description includes the required Goal, Implementation, and Testing sections and explains the fix and verification clearly.
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
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/fast-event-parser-mentions

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 PMD (7.25.0)
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/direct/UserGroupMemberAdapter.kt

No java executable found in PATH


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

🤖 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/parser2/direct/MessageAdapter.kt`:
- Around line 129-132: Check the explicit-null behavior for the new mention
fields in MessageAdapter against DownstreamMessageDto and make them consistent.
Verify whether mentioned_here, mentioned_channel, mentioned_groups, and
mentioned_roles are nullable or non-null in the DTO; if any are non-null, update
the direct parser to reject explicit nulls like the DTO path does instead of
using readNullableBoolean/parseList/parseStringList. Keep the parsing parity
aligned with the existing patterns used for pinned, silent, thread_participants,
and i18n, and reference MessageAdapter plus DownstreamMessageDto when making the
change.
🪄 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

Run ID: 97ca36f5-0969-4489-8b03-71a141400934

📥 Commits

Reviewing files that changed from the base of the PR and between 47bf435 and ee48bf0.

📒 Files selected for processing (7)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/DirectEventParser.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/direct/MessageAdapter.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/direct/UserGroupAdapter.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/direct/UserGroupMemberAdapter.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/MessageParsingTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/NewMessageEventParsingTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/testdata/MessageTestData.kt

@gpunto gpunto force-pushed the fix/fast-event-parser-mentions branch 2 times, most recently from 2eb085b to acf10d7 Compare June 26, 2026 15:27
@gpunto gpunto force-pushed the fix/fast-event-parser-mentions branch from acf10d7 to cbdf29e Compare June 26, 2026 15:53
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

pr:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant