IBM / java-sdk-core

Core functionality required by Java code generated by the IBM Cloud OpenAPI SDK Generator (openapi-sdkgen)
https://ibm.github.io/java-sdk-core/
Apache License 2.0
20 stars 21 forks source link

Deserialization target class for discriminator value: search #167

Closed CristianPerezGraj closed 2 years ago

CristianPerezGraj commented 2 years ago

Hi,

I´m getting the next issue and I looking for help;

image

Its happening on com.ibm.cloud.sdk.core.util.DiscriminatorBasedTypeAdapterFactory.java line 256, This looks like the assistant its returning more objects as usual and the SDK its generating and issue trying to convert it in LogCollection object.

Thanks in advice for your help.

padamstx commented 2 years ago

This error indicates that the service is returning a response object that can't be unmarshalled properly because the value of the discriminator property is "search" but there is no mapping for the value "search" to a viable model class. This is most likely resulting from using an older version of the SDK whereas the service has been updated to support additional discriminated subtypes (one of which is associated with the "search" value). Make sure that you are using the latest version of the Watson Java SDK. If the problem still occurs after that, then you'll need to open an issue with the Watson Java SDK project so they can start the investigation.

padamstx commented 2 years ago

Follow-up: I double-checked the assistant-v1 API definition located here: https://cloud.ibm.com/apidocs/assistant/assistant-v1 and the RuntimeResponseGeneric schema does not define a mapping for the value "search". So, it looks like perhaps the service is returning a response that doesn't comply with the API definition.

cc: @kevinkowa

CristianPerezGraj commented 2 years ago

Yes @padamstx that is correct, Im thinking in this moment that all of those fields are new customized new ones, added in the Watson Assistant Bot, and returned from the API. That why my assumption are the SDK its not prepared for receive custom fields added to the Assistant. I create the entire object structure manually and haves a lot of fields different that the documentation.

Maybe Im wrong on that assumpion?? Im a lot confused on this.

If you need a response JSON file with those fields Im able to upload it.

padamstx commented 2 years ago

@repjarms Jeff, I think this problem needs to be addressed in the Watson Java SDK. It looks like the assistant v1 service is returning an unexpected subclass of the RuntimeResponseGeneric schema (which uses oneOf to do polymorphism), specifically one with a discriminator value of "search" which is not included in the discriminator mapping within the API definition. If this is due to a legitimate update of the service, then perhaps all that needs to be done to solve this is update the API definition to include the new subclass(es) and discriminator value(s) and then re-gen the SDKs.

jeff-arn commented 2 years ago

Thanks @padamstx @CristianPerezGraj for discussing this - let me talk through this with the team and see if this is something that needs to be addressed in the API def and the Java SDK.

padamstx commented 2 years ago

@CristianPerezGraj It might help in the investigation if you could go ahead and attach a sample response to the issue here.

kevinkowa commented 2 years ago

From the looks of it, it might be an issue with using both v1 and v2 API. There's possibly some logs that contain a search response that is not available in v1. Quite strange, but we will add it to our backlog.

v1 runtime API does not return search responses. You can only get search responses from the v2 API

padamstx commented 2 years ago

@kevinkowa It's probably time to open up an issue against the Watson Java SDK and close this one out.