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

Add defences for bad APIs #1485

Merged
merged 2 commits into from
Jan 23, 2020
Merged

Add defences for bad APIs #1485

merged 2 commits into from
Jan 23, 2020

Conversation

0nko
Copy link
Contributor

@0nko 0nko commented Jan 23, 2020

This PR makes all gateway response parameters nullable and even handles possible empty strings in place of integers.

@0nko 0nko requested a review from nbradbury January 23, 2020 11:41
@nbradbury nbradbury self-assigned this Jan 23, 2020
@@ -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?,
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@nbradbury nbradbury self-requested a review January 23, 2020 13:17
Copy link
Contributor

@nbradbury nbradbury left a comment

Choose a reason for hiding this comment

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

:shipit:

@nbradbury nbradbury merged commit 41c392f into develop Jan 23, 2020
@0nko 0nko deleted the fix/nullable-gateway-params branch January 24, 2020 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants