Skip to content
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

Fix twin desired property payload conversion - MQTT #3322

Merged

Conversation

tmahmood-microsoft
Copy link
Contributor

No description provided.

@@ -1158,7 +1158,7 @@ private void HandleReceivedDesiredPropertiesUpdateRequest(MqttApplicationMessage
// This message is always QoS 0, so no ack will be sent.
receivedEventArgs.AutoAcknowledge = true;

Dictionary<string, object> desiredPropertyPatchDictionary = _payloadConvention.GetObject<Dictionary<string, object>>(receivedEventArgs.ApplicationMessage.Payload);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was _payloadConvention null here or something? Why do we want to always use the default payload convention?

Copy link
Contributor Author

@tmahmood-microsoft tmahmood-microsoft May 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the payload from service client is always converted using default Payload/Newtonsoft.Json

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good then. Leave a comment to that effect here for future reference.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to adding a comment in here explaining why default convention is used. You could reference the fact that we deserialize this into a dictionary based on service defined convention of it being a utf-8 encoded json string.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the payload from service client is always converted using default Payload/Newtonsoft.Json

Not quite. However it was sent from the service client, it is just JSON.

The problem is that our SDK deserializes the twin using Newtonsoft.Json. Then, individual properties can be deserialized to the user's choice, but not until after we've converted them back to bytes using the default payload convention again.

@tmahmood-microsoft
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@tmahmood-microsoft tmahmood-microsoft merged commit 24b016e into previews/v2 May 3, 2023
@tmahmood-microsoft tmahmood-microsoft deleted the tmahmood/mqtt-desired-properties-conversionFix branch May 3, 2023 16:44
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.

4 participants