I don't think the client library is wrapping oauth errors into a googleapi.Error.
Client
Storage
Environment
ECS Service on AWS
Code
package main
func main() {
bucket := "..."
path := "..."
r := bytes.NewReader("...")
w := s.Bucket(bucket).Object(path).NewWriter(ctx)
w.ContentType = "application/gzip"
= io.Copy(w, in.Body)
if err = w.Close(); err != nil {
var gErr *googleapi.Error
if errors.As(err, &gErr) {
if gErr.Code >= 400 && gErr.Code <= 499 {
fmt.Println("client error")
} else {
panic(err)
}
} else {
panic(err)
}
}
}
Expected behavior
I think ideally this should be wrapped into a googleapi.Error. Or at least, the other potential error types could be better documented.
https://pkg.go.dev/cloud.google.com/go/storage?tab=doc
Errors returned by this client are often of the type [`googleapi.Error`](https://godoc.org/google.golang.org/api/googleapi#Error). These errors can be introspected for more information by type asserting to the richer `googleapi.Error` type. For example:
if e, ok := err.(*googleapi.Error); ok {
if e.Code == 409 { ... }
}
Actual behavior
The error returned is not wrapped into a googleapi.Error.
oauth2: cannot fetch token: 400 Bad Request
Response: {"error":"invalid_grant","error_description":"Invalid JWT: iss field missing."}
Screenshots
N/A
Additional context
N/A
I don't think the client library is wrapping oauth errors into a
googleapi.Error.Client
Storage
Environment
ECS Service on AWS
Code
Expected behavior
I think ideally this should be wrapped into a
googleapi.Error. Or at least, the other potential error types could be better documented.https://pkg.go.dev/cloud.google.com/go/storage?tab=doc
Actual behavior
The error returned is not wrapped into a
googleapi.Error.Screenshots
N/A
Additional context
N/A