Skip to content

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

@agrare

Description

@agrare

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions