You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The startSubscription method in WebSocketConnectionManager attempts to convert a Subscription's variables into JSON by just calling JSONObject(map) over the subscription's valueMap() (see line 123 of WebSocketConnectionManager).
This is dangerous, because the JSONObject(map) constructor, in android API 19 to 30, cannot handle maps that have values which are enums, it nulls them out (specifically, see the wrap(Object o) method of JSONObject in these API versions).
This means that when a Subscription has a non-nullable input variable that is an apollo generated ENUM, WebSocketConnectionManager will null it before sending it to the service, which ofcourse will cause the service to throw an error.
WebSocketConnectionManager should use the generated Variables.marshaller().marshal(..) method to properly JSON-ify the subscription's variables. This can be seen in PR #351 .
To Reproduce
Steps to reproduce the behavior:
create a graphql subscription with a non-nullable ENUM as input.
attempt to execute a subscription execution on that subscription
observe that line 123 of WebSocketConnectionManager nulls the enum's value in the JSON Object.
observe error message recieved from backend on that subscription.
To Reproduce via Unit Test
to quickly observe the nulling effect, run the following unit test:
Expected behavior
Enums sent via WebSocketConnectionManager should NOT be nulled before sent out. I imagine this is probably a bug for any non primitive object too (my PR should fix), i just happened to have observed it for enums.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment(please complete the following information):
AppSync SDK Version: 3.1.4
Device Information (please complete the following information):
Device: Any
Android API Version: from 19 to 30
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
Describe the bug
The
startSubscription
method inWebSocketConnectionManager
attempts to convert aSubscription
's variables into JSON by just callingJSONObject(map)
over the subscription'svalueMap()
(see line 123 ofWebSocketConnectionManager
).This is dangerous, because the
JSONObject(map)
constructor, in android API 19 to 30, cannot handle maps that have values which are enums, it nulls them out (specifically, see thewrap(Object o)
method ofJSONObject
in these API versions).This means that when a Subscription has a non-nullable input variable that is an apollo generated ENUM,
WebSocketConnectionManager
will null it before sending it to the service, which ofcourse will cause the service to throw an error.WebSocketConnectionManager
should use the generatedVariables.marshaller().marshal(..)
method to properly JSON-ify the subscription's variables. This can be seen in PR #351 .To Reproduce
Steps to reproduce the behavior:
To Reproduce via Unit Test
to quickly observe the nulling effect, run the following unit test:
Expected behavior
Enums sent via
WebSocketConnectionManager
should NOT be nulled before sent out. I imagine this is probably a bug for any non primitive object too (my PR should fix), i just happened to have observed it for enums.Screenshots
If applicable, add screenshots to help explain your problem.
Environment(please complete the following information):
Device Information (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: