databricks-sdk-go
databricks-sdk-go copied to clipboard
[ISSUE] `apierr.GetAPIError` does not unmarshal `ErrorCode` correctly
Description
apierr.GetAPIError does not unmarshal ErrorCode correctly
Reproduction
Below is a simplified version of parseErrorFromResponse
func main() {
myError := apierr.APIError{
ErrorCode: "RESOURCE_DOES_NOT_EXIST",
Message: "Path (/Users/abc) doesn't exist.",
}
b, err := json.Marshal(myError)
if err != nil {
panic(err)
}
print(b)
var errorBody struct {
ErrorCode any `json:"error_code,omitempty"`
Message string `json:"message,omitempty"`
}
err = json.Unmarshal(b, &errorBody)
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", errorBody)
}
Expected behavior errorBody should be populated with ErrorCode & Message, however, ErrorCode is nil in this case
{ErrorCode:<nil> Message:Path (/Users/abc) doesn't exist.}