-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(go/adbc/driver/flightsql): Improvements for flightSql error details #2185
Changes from all commits
c0f714b
d767fe6
713a93e
6dfc6a9
531e148
8333e89
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ package flightsql | |
|
||
import ( | ||
"context" | ||
"errors" | ||
"fmt" | ||
"strings" | ||
|
||
|
@@ -30,13 +31,15 @@ import ( | |
"google.golang.org/protobuf/types/known/anypb" | ||
) | ||
|
||
const grpcStatusDetailsBin = "grpc-status-details-bin" | ||
|
||
func adbcFromFlightStatus(err error, context string, args ...any) error { | ||
var header, trailer metadata.MD | ||
return adbcFromFlightStatusWithDetails(err, header, trailer, context, args...) | ||
} | ||
|
||
func adbcFromFlightStatusWithDetails(err error, header, trailer metadata.MD, context string, args ...any) error { | ||
if _, ok := err.(adbc.Error); ok { | ||
if ok := errors.Is(err, adbc.Error{}); ok { | ||
return err | ||
} | ||
|
||
|
@@ -84,7 +87,13 @@ func adbcFromFlightStatusWithDetails(err error, header, trailer metadata.MD, con | |
|
||
details := []adbc.ErrorDetail{} | ||
for _, detail := range grpcStatus.Proto().Details { | ||
details = append(details, &anyErrorDetail{name: "grpc-status-details-bin", message: detail}) | ||
if detailProto, err := detail.UnmarshalNew(); err != nil { | ||
// if we could decode into proto, use ProtobufErrorDetail | ||
details = append(details, &adbc.ProtobufErrorDetail{Name: grpcStatusDetailsBin, Message: detailProto}) | ||
} else { | ||
// proceed with any, maybe the user knows how to deserialize? | ||
details = append(details, &anyErrorDetail{name: grpcStatusDetailsBin, message: detail}) | ||
} | ||
} | ||
|
||
// XXX(https://github.com/grpc/grpc-go/issues/5485): don't count on | ||
|
@@ -97,7 +106,7 @@ func adbcFromFlightStatusWithDetails(err error, header, trailer metadata.MD, con | |
case key == "content-type": | ||
// Not useful info | ||
continue | ||
case key == "grpc-status-details-bin": | ||
case key == grpcStatusDetailsBin: | ||
// gRPC library parses this above via grpcStatus.Proto() | ||
continue | ||
case strings.HasSuffix(key, "-bin"): | ||
|
@@ -107,6 +116,9 @@ func adbcFromFlightStatusWithDetails(err error, header, trailer metadata.MD, con | |
} | ||
default: | ||
for _, value := range values { | ||
if strings.HasPrefix(value, "Grpc-") { | ||
continue | ||
} | ||
details = append(details, &adbc.TextErrorDetail{Name: key, Detail: value}) | ||
} | ||
} | ||
|
@@ -116,7 +128,7 @@ func adbcFromFlightStatusWithDetails(err error, header, trailer metadata.MD, con | |
case key == "content-type": | ||
// Not useful info | ||
continue | ||
case key == "grpc-status-details-bin": | ||
case key == grpcStatusDetailsBin: | ||
// gRPC library parses this above via grpcStatus.Proto() | ||
continue | ||
case strings.HasSuffix(key, "-bin"): | ||
|
@@ -126,6 +138,9 @@ func adbcFromFlightStatusWithDetails(err error, header, trailer metadata.MD, con | |
} | ||
default: | ||
for _, value := range values { | ||
if strings.HasPrefix(value, "Grpc-") { | ||
continue | ||
} | ||
Comment on lines
+141
to
+143
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same question as above |
||
details = append(details, &adbc.TextErrorDetail{Name: key, Detail: value}) | ||
} | ||
} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. Isn't this strictly worse now? Because without any, you have to know the actual Protobuf type in advance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it appears so. I guess we can scrap this PR if there's nothing useful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why skip things with
Grpc-
prefix?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why and how, but I was getting TextErrorDetails with key
trailer
and valueGrpc-Status
andGrpc-Message
andGrpc-Status-Details-Bin
. I don't think those values can be useful.