Bug in response serialization when the response type is a string

Hello! I think I've discovered a bug in the Python SDK. I opened a Customer Care case, and they told me to report it here, so here you have the description:

Hello

I have found a bug in the Genesys Cloud Python SDK.

The request GET /api/v2/integrations/actions/{actionId}/templates/{fileName} returns a json-serializable string.

However, when making the request using the Python SDK:

IntegrationsApi().get_integrations_action_template(action_id, file_name)

The method returns a string that is not json-serializable.

For example, if the endpoint returns this:

"{\"hello\": \"world\"}"

The SDK method returns this:
"{'hello': 'world'}"

Which is not a valid JSON, as it has simple quotes instead of double quotes.

Digging into the SDK's code, I've seen that it may be caused by how it deserializes the API response. In this line it turns the json-string into a python dict, and then it is converted back into a string. And as python dicts use simple quotes, that provokes the bug. I think that when the response_type is str, it should not try to parse the response string, but return it directly.

Could you have a look at it?

Thank you

Edit after Solution: The bug was not that the method should return a JSON serializable string. It should simply return the action template string. However, if that template happened to be JSON serializable, then the SDK would both serialize and deserialize it, modifying it.

Were you able to have a look at this?

Hi Adrian,

Thanks for bringing this up. I will open a ticket with my team.

Thanks,
John Carnell
Director, Developer Engagement

1 Like

Hello. Any updates about this? I see that in the current version (215.0.0) still happens.

Hi Adrian,

It is still in our Backlog. We just picked it up from the backlog, are investigating, and hope to fix it this next Sprint.

Thanks,
John

1 Like

Hello,

The fix should be in the latest SDK (217.0.0).
The issue was that there are a couple of endpoints (3 I think) which return a text/plain response (all the other return application/json). So the SDK was attempting to parse the string as a json string/content.
The SDK now takes into account these text content types.

Regards,

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.