WebhookApi.listWebhooks() throws HttpException
Actual: WebhookApi.listWebhooks() throws HttpException
Error message:
HttpException.Error(code=null, message=Cannot deserialize value of type java.util.LinkedHashMap<java.lang.String,java.lang.String> from Array value (token JsonToken.START_ARRAY)
at [Source: REDACTED (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION disabled); line: 1, column: 212] (through reference chain: com.crowdin.client.webhooks.model.WebhookResponseList["data"]->java.util.ArrayList[0]->com.crowdin.client.webhooks.model.WebhookResponseObject["data"]->com.crowdin.client.webhooks.model.Webhook["headers"]))
Expected: WebhookApi.listWebhooks() returns ResponseList<Webhook>
Up to me its looks loike mapping error. If I change in WebHookApi.java:45
WebhookResponseList webhookResponseList = this.httpClient.get(this.url + "/projects/" + projectId + "/webhooks", new HttpRequestConfig(queryParams), WebhookResponseList.class); to WebhookResponseList webhookResponseList = this.httpClient.get(this.url + "/projects/" + projectId + "/webhooks", new HttpRequestConfig(queryParams), Object.class); there is no exception threw.
How to reproduce: Setup at least one webhook in crowndin without any headers. If all webhooks have not empty headers then no exception.
After de5dfe77b969d81d94ee362df59be8a714d7d859 headers for new webhook can't be provided as array/list, so looks like the exception above is caused by deserialization of old data structure.
@Marzuh do you reproduce it on clean environment with the latest version of the library? @andrii-bodnar, does this need some backward compatibility solution for such cases (changes are already quite old)?
@Besomhead I haven't released it yet, but yes, we should keep it backwards compatible. Isn't it backwards compatible?
@Besomhead I haven't released it yet, but yes, we should keep it backwards compatible. Isn't it backwards compatible?
@andrii-bodnar I'm not sure how webhooks are stored and can only make assumptions about what happened in Marzuh's case. Looks like there could be situation when we try to read old webhooks that were created when old request code allowed to pass headers as list of strings (general object prior to that). So, it could probably be resolved with simple DB/storage migration, like removing or updating webhooks with invalid headers, or we can create temporary code that should be removed in the next release, it could catch this particular mapping exception and convert headers to correct representation when constructing response object.
@Besomhead not sure if I understood you correctly, the API only accepts and returns the event types that are listed in the docs - Add Webhook.