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

UniqueArguments omitted when serializing a webhook event #493

Closed
Jericho opened this issue Jun 1, 2023 · 6 comments
Closed

UniqueArguments omitted when serializing a webhook event #493

Jericho opened this issue Jun 1, 2023 · 6 comments
Assignees
Labels
Bug This change resolves a defect
Milestone

Comments

@Jericho
Copy link
Owner

Jericho commented Jun 1, 2023

@elmalakai pointed out that UniqueArguments is omitted when serializing a webhook event.

@Jericho Jericho added the Bug This change resolves a defect label Jun 1, 2023
@Jericho Jericho added this to the 0.101.0 milestone Jun 1, 2023
@Jericho Jericho self-assigned this Jun 1, 2023
@Jericho
Copy link
Owner Author

Jericho commented Jun 1, 2023

@elmalakai here's a beta version of the next package that will properly serialize uniqueargs: https://www.myget.org/feed/jericho/package/nuget/StrongGrid/0.101.0-beta0005

The only concession we have to make is that unique arguments with a numerical value will be serialized as a string like so:

"reseller_id": "1234"

which is not 100% same as the original JSON received from SendGrid but it's the best we can do due to the fact that unknown values must be cast as string in order to be added to the Dictionary<string, string>.

@elmalakai
Copy link

I struggle with this a lot in dealing with JSON everywhere. Lately I use Dictionary<string,object> and use one of the many System.Text.Json 'generic' object converters out there to store the value as strongly typed (double, bool, null, string, array).

I think for now, treating all unique arguments as strings is acceptable. Most of these arguments you add yourself to the message, so you know best how to parse and deal with them.

@Jericho Jericho closed this as completed in 04ba8b2 Jun 2, 2023
@Jericho
Copy link
Owner Author

Jericho commented Jun 2, 2023

Thanks for confirming.

@elmalakai
Copy link

Looks like you had an bug in 0.101.0-beta0005 but I think you've fixed it. I tried to write a test case for it and it's working. Specifically, the UniqueArguments were being double wrapped in double quotes when deserialized:

? events[0].UniqueArguments["environment"]
"\"Production\""

Tried to write a test case for it, but I think you beat me to it (Webhook_includes_unknow_property).

@Jericho
Copy link
Owner Author

Jericho commented Jun 2, 2023

Yes, I confirm there was an issue with quotes being doubled but fixed it here: 04ba8b2#diff-bbf883778fe4acba4cb2d3272c16d800f7dcc6fcbf69c03f9415607d4af110fdR115

Using .GetRawText() to get the content of a JSON node containing a string includes the double quotes evidently (I didn't know). It's not a problem with nodes containing numerical values though.

@Jericho
Copy link
Owner Author

Jericho commented Jun 2, 2023

🎉 This issue has been resolved in version 0.101.0 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This change resolves a defect
Projects
None yet
Development

No branches or pull requests

2 participants