-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ablyMessage.Data
type changed after encryption was added
#608
Comments
➤ Automation for Jira commented: The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-3729 |
@codegoalie we are looking into the issue and will fix it asap 👍 |
Related to #370 |
Hi, @codegoalie I have added test cases to check for encoding/decoding of JSON string data with/without cipher. You can check here https://github.com/ably/ably-go/pull/609/files. Encoding/Decoding for JSON in string format seems to be working just fine 🤔. |
That did not appear to work. Here's a minimal code from our side. I'm working with our vendor to see about getting a sample of the producer-side: unsubscribe, err := channel.SubscribeAll(context.Background(), func(msg *ably.Message) {
log.Info("received message", "data_type", reflect.TypeOf(msg.Data), "data", msg.Data)
var event Event
err = json.Unmarshal([]byte(msg.Data.(string)), &event)
// ...
}) The log used to read that
|
Yeah, it will be good if we can see the code from producer side, mainly it will be a publish method. |
Hi @codegoalie
I suspect the message being received also has If so, then the issue is that, before commit 4672dd4, the Go realtime client was not automatically decoding received data as it should do, and so the data was always coming through as a This can be reproduced by publishing a client, err := ably.NewRealtime(
ably.WithKey("<key>"),
)
if err != nil {
return err
}
channel := client.Channels.Get("test")
msgC := make(chan *ably.Message)
unsub, err := channel.SubscribeAll(context.Background(), func(msg *ably.Message) {
msgC <- msg
})
if err != nil {
return err
}
defer unsub()
log.Println("publishing JSON message")
if err := channel.Publish(context.Background(), "test", map[string]string{"foo": "bar"}); err != nil {
return err
}
log.Println("waiting for message")
msg := <-msgC
log.Printf("got message data_type=%T data=%v encoding=%q", msg.Data, msg.Data, msg.Encoding)
return nil In release
and on
I think we need to treat this as a breaking change, revert from the v1.x branch, and queue up automatically decoding data for ably-go v2 (although we'll likely want something type safe in v2, see #584). |
@lmars I think this is the only case I can think of! |
Hi, @codegoalie since changes on the main are breaking for you and might reoccur for other users, we have reverted the change on the main branch. We will soon be implementing real-time encryption support on the v2 branch (or branch with similar name). Let us know if you need anything else : ) |
Ok! Sounds good. Thanks for looking into it and keeping backwards compatibility. Looking forward to v2! |
Closing the issue since the change has been reverted and new implementation will be done as per #615 |
In
v1.2.12
, the stream I am connecting to provided messages with aData
attribute of typestring
(a string of JSON text). However, after upgrading to the latest commit (specifically 4672dd4 or later), I'm getting messages withData
of typemap[string]interface{}
. Nothing has changed with the publisher. In fact, if I revert back tov1.2.12
, theData
type goes back tostring
.Here's the relevant subscription code:
And the output on
v1.2.12
:And on 4672dd4 or later:
Am I doing something wrong, or is this a regression?
Thanks so much!
┆Issue is synchronized with this Slack message by Unito
The text was updated successfully, but these errors were encountered: