IBM / ruby-sdk-core

The ruby-sdk-core repository contains core functionality required by Ruby code generated by the IBM OpenAPI SDK Generator.
Apache License 2.0
2 stars 10 forks source link

IBMCloudSdkCore::ApiException raises JSON parser exception for XML errors #38

Open agrare opened 2 years ago

agrare commented 2 years ago

While executing a GET https://resource-controller.cloud.ibm.com/v2/resource_instances/ID an error is returned in XML format:

<HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY>\nAn error occurred while processing your request.<p>\nReference&#32;&#35;97&#46;a5a83817&#46;1649175424&#46;3958d93\n</BODY></HTML>\n

Which then fails here https://github.com/IBM/ruby-sdk-core/blob/main/lib/ibm_cloud_sdk_core/api_exception.rb#L15 trying to parse this as JSON:

[JSON::ParserError]: 859: unexpected token at '<HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY>\nAn error occurred while processing your request.<p>\nReference&#32;&#35;97&#46;a5a83817&#46;1649175424&#46;3958d93\n</BODY></HTML>\n
/opt/IBM/infrastructure-management-gemset/gems/json-2.6.1/lib/json/common.rb:216:in `parse'
/opt/IBM/infrastructure-management-gemset/gems/json-2.6.1/lib/json/common.rb:216:in `parse'
/opt/IBM/infrastructure-management-gemset/gems/ibm_cloud_sdk_core-1.1.3/lib/ibm_cloud_sdk_core/api_exception.rb:15:in `initialize'
/opt/IBM/infrastructure-management-gemset/gems/ibm_cloud_sdk_core-1.1.3/lib/ibm_cloud_sdk_core/base_service.rb:113:in `new'
/opt/IBM/infrastructure-management-gemset/gems/ibm_cloud_sdk_core-1.1.3/lib/ibm_cloud_sdk_core/base_service.rb:113:in `request'

I'm unsure if API errors in XML format are possible and should be handled by this library, or if the service returning an XML formatted error is the underlying bug here (seems more likely).