-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add defences for bad APIs #1485
Conversation
@@ -75,10 +75,10 @@ constructor( | |||
@SerializedName("id") val gatewayId: String, | |||
@SerializedName("title") val title: String?, | |||
@SerializedName("description") val description: String?, | |||
@SerializedName("order") val order: Int, | |||
@SerializedName("enabled") val enabled: Boolean, | |||
@SerializedName("order") val order: String?, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@0nko I feel like I need some background here. Why are we treating "order" as a string when the API docs say it's an integer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nbradbury I should have linked this, sorry - woocommerce/woocommerce-android#1840
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@0nko What will happen now if the response contains "order" as an int?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll work automatically, Gson will treat it as a string. I tested it to make sure but I haven't created a separate client PR because there's another FluxC PR I want to include in the hotfix. You can just reference this commit to test it yourself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR makes all gateway response parameters nullable and even handles possible empty strings in place of integers.