diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b75af59..ccbc0422 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.12.1] - 2023-05-01 +### Fixed +* Fixed parsing of errors in queries ## [0.12.0] - 2023-05-01 ### Added diff --git a/kusto/internal/frames/v2/decoder_test.go b/kusto/internal/frames/v2/decoder_test.go index 7b86a5aa..61da3f9b 100644 --- a/kusto/internal/frames/v2/decoder_test.go +++ b/kusto/internal/frames/v2/decoder_test.go @@ -2,6 +2,7 @@ package v2 import ( "context" + "encoding/json" "io" "strings" "testing" @@ -344,8 +345,31 @@ func TestErrorDecode(t *testing.T) { }, { "FrameType":"DataSetCompletion", - "HasErrors":false, - "Cancelled":false + "HasErrors":true, + "Cancelled":false, + "OneApiErrors": [{ + "error": { + "code": "LimitsExceeded", + "message": "Request is invalid and cannot be executed.", + "@type": "Kusto.Data.Exceptions.KustoServicePartialQueryFailureLimitsExceededException", + "@message": "Query execution has exceeded the allowed limits (80DA0003): .", + "@context": { + "timestamp": "2018-12-10T15:10:48.8352222Z", + "machineName": "RD0003FFBEDEB9", + "processName": "Kusto.Azure.Svc", + "processId": 4328, + "threadId": 7284, + "appDomainName": "RdRuntime", + "clientRequestId": "KPC.execute;d3a43e37-0d7f-47a9-b6cd-a889b2aee3d3", + "activityId": "a57ec272-8846-49e6-b458-460b841ed47d", + "subActivityId": "a57ec272-8846-49e6-b458-460b841ed47d", + "activityType": "PO-OWIN-CallContext", + "parentActivityId": "a57ec272-8846-49e6-b458-460b841ed47d", + "activityStack": "(Activity stack: CRID=KPC.execute;d3a43e37-0d7f-47a9-b6cd-a889b2aee3d3 ARID=a57ec272-8846-49e6-b458-460b841ed47d > PO-OWIN-CallContext/a57ec272-8846-49e6-b458-460b841ed47d)" + }, + "@permanent": false + } + }] } ] ` @@ -442,9 +466,36 @@ func TestErrorDecode(t *testing.T) { }, DataSetCompletion{ Base: Base{FrameType: "DataSetCompletion"}, - HasErrors: false, + HasErrors: true, Cancelled: false, - Op: errors.OpQuery, + OneAPIErrors: []interface{}{ + map[string]interface{}{ + "error": map[string]interface{}{ + "@context": map[string]interface{}{ + "activityId": "a57ec272-8846-49e6-b458-460b841ed47d", + "activityStack": "(Activity stack: CRID=KPC.execute;d3a43e37-0d7f-47a9-b6cd-a889b2aee3d3 ARID=a57ec272-8846-49e6-b458-460b841ed47d > PO-OWIN-CallContext/a57ec272-8846-49e6-b458-460b841ed47d)", + "activityType": "PO-OWIN-CallContext", + "appDomainName": "RdRuntime", + "clientRequestId": "KPC.execute;d3a43e37-0d7f-47a9-b6cd-a889b2aee3d3", + "machineName": "RD0003FFBEDEB9", + "parentActivityId": "a57ec272-8846-49e6-b458-460b841ed47d", + "processId": json.Number("4328"), + "processName": "Kusto.Azure.Svc", + "subActivityId": "a57ec272-8846-49e6-b458-460b841ed47d", + "threadId": json.Number("7284"), + "timestamp": "2018-12-10T15:10:48.8352222Z", + }, + "@message": "Query execution has exceeded the allowed limits (80DA0003): .", + "@permanent": false, + "@type": "Kusto.Data.Exceptions.KustoServicePartialQueryFailureLimitsExceededException", + "code": "LimitsExceeded", + "message": "Request is invalid and cannot be executed.", + }, + }, + }, + Error: *errors.ES(errors.OpUnknown, errors.KLimitsExceeded, "Request is invalid and cannot be executed.;See https://docs.microsoft."+ + "com/en-us/azure/kusto/concepts/querylimits"), + Op: errors.OpQuery, }, } diff --git a/kusto/internal/frames/v2/v2.go b/kusto/internal/frames/v2/v2.go index e41ebb93..9432b67f 100644 --- a/kusto/internal/frames/v2/v2.go +++ b/kusto/internal/frames/v2/v2.go @@ -86,9 +86,10 @@ type DataSetCompletion struct { // Cancelled indicates that the request was cancelled. Cancelled bool // OneAPIErrors is a list of errors encountered. - OneAPIErrors []string `json:"OneApiErrors"` + OneAPIErrors []interface{} `json:"OneApiErrors"` - Op errors.Op `json:"-"` + Error errors.Error + Op errors.Op `json:"-"` } // IsFrame implements frame.Frame. @@ -98,8 +99,13 @@ func (DataSetCompletion) IsFrame() {} func (d *DataSetCompletion) UnmarshalRaw(raw json.RawMessage) error { err := json.Unmarshal(raw, &d) if err != nil { - err = errors.GetCombinedError(fmt.Errorf("json parsing failed: %v", raw), err) + err = errors.GetCombinedError(fmt.Errorf("json parsing failed: %v", string(raw)), err) + } else { + if d.HasErrors { + d.Error = *errors.OneToErr(map[string]interface{}{"OneApiErrors": d.OneAPIErrors}, d.Op) + } } + return err } diff --git a/kusto/internal/version/version.go b/kusto/internal/version/version.go index 96f13355..5c983cb8 100644 --- a/kusto/internal/version/version.go +++ b/kusto/internal/version/version.go @@ -2,4 +2,4 @@ package version // Kusto is the version of this client package that is communicated to the server. -const Kusto = "0.12.0" +const Kusto = "0.12.1" diff --git a/quickstart/go.mod b/quickstart/go.mod index f5e1f114..ce5c0b77 100644 --- a/quickstart/go.mod +++ b/quickstart/go.mod @@ -2,7 +2,7 @@ module github.com/Azure/azure-kusto-go/quickstart go 1.19 -require github.com/Azure/azure-kusto-go v0.12.0 +require github.com/Azure/azure-kusto-go v0.12.1 require ( github.com/Azure/azure-pipeline-go v0.1.8 // indirect