awslabs / awslabs/aws-mobile-appsync-sdk-android

Subscription initialization throws "Invalid message type string" exception when token has expired

Open
#246 3 comments 7 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
106
Forks
56
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
The issue happens when app tries to initialize subscription with an expired token.
`WebSocketConnectionManager.processJsonMessag(websocket, message)` gets as message:

`{"type":"connection_error","payload":{"errors":[{"errorType":"Unauthorized","errorCode":401}]}}`

which cannot be parsed because **connection_error** does not exists in MessageType enum.
So the result is `IllegalArgumentException("Invalid message type string");`

**To Reproduce**
Steps to reproduce the behavior:
Provide expired token during subscription initialization.

**Expected behavior**
New MessageType suitable to code 401 should be added so `IllegalArgumentException("Invalid message type string");` won't be thrown. And subscription request should be repeated with the refreshed token.

**Environment(please complete the following information):**
- AppSync SDK Version: 3.0.1

**Device Information (please complete the following information):**
- Samsung Galaxy S7 edge
- Android Version: 8.0.0

Contributor guide

Open the contributing guide

Research direction

Start at WebSocketConnectionManager.processJsonMessag(websocket, message) and inspect the MessageType enum to trace handling of the connection_error payload. Reproduce subscription initialization with an expired token; done means the 401 response no longer causes IllegalArgumentException and the subscription request is retried with the refreshed token.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, graphql, java
Domain
api, authentication
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.