Skip to content

fix websocket and restore describeview#100

Open
saipreetham16 wants to merge 2 commits intomainfrom
sleburu/fix-websocket-and-restore-describeview
Open

fix websocket and restore describeview#100
saipreetham16 wants to merge 2 commits intomainfrom
sleburu/fix-websocket-and-restore-describeview

Conversation

@saipreetham16
Copy link
Contributor

Description:

Summary

This PR restores the previously reverted DescribeView feature and fixes the WebSocket crash caused by force-unwrapping
optional JSON fields in WebSocket message handlers.

Background

The DescribeView feature (PR #96) was reverted in PR #98 due to a reported crash (JSONException: No value for MessageId).
Investigation confirmed that:

  • The crash is in WebSocketManager.handleMetadata() — a pre-existing bug unrelated to DescribeView
  • The DescribeView commit never modified WebSocketManager.kt
  • The crash occurs when interactive messages include MessageMetadata without a MessageId field, and the SDK uses
    getString() (which throws) instead of optString() (which returns a default)

Changes

1. Restore DescribeView API support

  • Re-reverts commit a8fd788 to restore describeView() across ChatSession, ChatService, and AWSClient
  • Adds ViewResourceContent model for ShowView block interactive messages
  • Adds View / ViewContent data models
  • Adds ViewContentView composable in example app

2. Fix: Loosen message property requirements in WebSocket handler

  • Replaces all getString() and getJSONObject() calls with optString() / optJSONObject() in WebSocketManager.kt
  • Affected methods: handleMessage, handleParticipantEvent, handleTyping, handleChatEnded, handleMetadata, handleAttachment
  • Missing fields gracefully default to empty strings instead of crashing

3. Version bump to 2.0.11

Testing

  • Unit tests: 23 new tests covering all handler methods with complete fields, missing fields, and edge cases (187
    total, 0 failures)
  • Example app — DescribeView: Verified with ShowView block flow — describeView() successfully fetches view schema
  • Example app — Interactive messages: Verified LIST PICKER and TIME PICKER flows work without crashes
  • Crash reproduction: Confirmed crash reproduces by stripping MessageId from WebSocket payloads, and confirmed fix
    resolves it

Replace all getString/getJSONObject calls with optString/optJSONObject
in WebSocketManager to prevent crashes when optional fields are missing
from WebSocket payloads. Bump version to 2.0.11.

Includes 23 unit tests covering all handler methods with complete
and missing field scenarios.

Fixes: #99
Related: P382365182
@saipreetham16 saipreetham16 requested a review from a team as a code owner February 28, 2026 07:13
@saipreetham16 saipreetham16 changed the title Sleburu/fix websocket and restore describeview fix websocket and restore describeview Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants