Operating System/Shell (used to run SDK-based apps):
Mac
Steps or code snippet to reproduce
Generate any exception with the VMC SDK. For example, deleting an SDDC that is in the process of being created, calling a get on an SDDC that does not exist, etc. When you try to convert the error to a string using the function str() the string you get back loses all information about the error.
Actual behavior
Calling delete on an SDDC that is in the process of being created returns an InvalidRequest which is correct but when we convert the error to a string we get {{messages : [], data : {{}}, error_type : None}}. The same thing happens with numerous other exceptions. However, we you call the to_json() function of the error, you get:
{"messages":[],"data":{"error_code":"skyscraper.sddc.not.ready.for.delete","error_messages":["Sddc is currently not in a state where it can be deleted. Please try once the status is READY or FAILED."],"retryable":false,"status":400,"path":"/vmc/api/orgs/REDACTED/sddcs/REDACTED"}}
Expected behavior
We should be returning an error message and the error type as strings something like {{messages : ['The sddc is not in a state that's valid for deletion'], data : {{}}, error_type : InvalidRequest }}. At the very least we should return the same string we get when we call the to_json() function of the error.
Environment
sdk package version: idem-vmc 1 /usr/local/src/ace/idem-vmc nsx-vmc-aws-integration-python-sdk 3.0.3.0.0.17723277 nsx-vmc-policy-python-sdk 3.0.3.0.0.17723277 pyvmomi 7.0.2 vapi-client-bindings 3.6.0 vapi-common-client 2.25.0 vapi-runtime 2.25.0 vmc-client-bindings 1.40.0 vmc-draas-client-bindings 1.17.0 vSphere-Automation-SDK 1.56.0
python version: Python 3.7.10
vSphere version: VMC
Operating System/Shell (used to run SDK-based apps): Mac
Steps or code snippet to reproduce
Generate any exception with the VMC SDK. For example, deleting an SDDC that is in the process of being created, calling a get on an SDDC that does not exist, etc. When you try to convert the error to a string using the function
str()
the string you get back loses all information about the error.Actual behavior
Calling delete on an SDDC that is in the process of being created returns an InvalidRequest which is correct but when we convert the error to a string we get
{{messages : [], data : {{}}, error_type : None}}
. The same thing happens with numerous other exceptions. However, we you call theto_json()
function of the error, you get:Expected behavior
We should be returning an error message and the error type as strings something like
{{messages : ['The sddc is not in a state that's valid for deletion'], data : {{}}, error_type : InvalidRequest }}
. At the very least we should return the same string we get when we call theto_json()
function of the error.