-
Notifications
You must be signed in to change notification settings - Fork 217
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
fix: return better error messages for grpc-gateway errors #1397
Conversation
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #1397 +/- ##
=======================================
Coverage 78.17% 78.17%
=======================================
Files 43 43
Lines 3239 3239
=======================================
Hits 2532 2532
Misses 565 565
Partials 142 142 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Impl looks good to me minus one comment. Could we add a unit or integration test as well? |
rpc/flipt/marshaller.go
Outdated
err := c.Decoder.Decode(v) | ||
if err != nil { | ||
if _, ok := err.(*json.UnmarshalTypeError); ok { | ||
return fmt.Errorf("invalid values for key(s) in json body") |
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.
This looks great. One extra suggestion: could we slip in a logger and log line in here?
Something to emit the original error out via logs.
error
level is the obvious choice. However, I wonder if this actually makes more sense at a debug
level.
Just thinking if someone spams the API with a bad request then debug
level might be more forgiving.
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.
@GeorgeMac Agreed, especially if someones client is configured badly. I can emit a debug level log here first than we can adjust if necessary.
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.
💯 sounds great!
@markphelps Definitely. I wanted to see if this was the right direction before I added test. Will add those tests though! |
rpc/flipt/marshaller.go
Outdated
err := c.Decoder.Decode(v) | ||
if err != nil { | ||
if _, ok := err.(*json.UnmarshalTypeError); ok { | ||
return fmt.Errorf("invalid values for key(s) in json body") |
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.
nit: could prob just use errors.New here since we aren't formatting anything
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.
@markphelps Done! Thanks.
de889c4
to
11ea5d0
Compare
an integration test for the behavior.
11ea5d0
to
51088be
Compare
@yquansah this should fix both FLI-129 and FLI-130 right? |
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.
lgtm!! thank you
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.
Wicked 💪
@all-contributors please add @yquansah for code |
I've put up a pull request to add @yquansah! 🎉 |
* main: (36 commits) feat(sdk/go): thread client token on RPC calls when provided (#1389) docs: update .all-contributorsrc [skip ci] docs: update README.md [skip ci] chore(deps): bump google.golang.org/protobuf in /_tools (#1401) chore(deps): bump google.golang.org/protobuf from 1.29.0 to 1.29.1 (#1400) fix: return better error messages for grpc-gateway errors (#1397) fix: import for cockroach db (#1399) chore(deps): bump golang.org/x/tools from 0.6.0 to 0.7.0 in /_tools (#1394) chore: update readme w better usecase verbiage (#1395) fix(sdk/go): documentation and example corrections chore(deps): bump google.golang.org/protobuf from 1.28.1 to 1.29.0 (#1393) chore(deps): bump google.golang.org/protobuf in /_tools (#1391) chore(sdk/go): fix README markdown style fix(sdk/go): drop support for single field message mangling chore(sdk/go): add README chore(gowork): go edit -fmt feat(sdk/go): add doc.go feat(sdk/go): add static client token provider refactor(sdk/go): move grpc transport into its own subpackage chore(proto): regenerate RPC using protoc-gen-go-grpc v1.3.0 ...
* namespaces: (31 commits) Release/1.19 (#1403) feat(sdk/go): thread client token on RPC calls when provided (#1389) docs: update .all-contributorsrc [skip ci] docs: update README.md [skip ci] chore(deps): bump google.golang.org/protobuf in /_tools (#1401) chore(deps): bump google.golang.org/protobuf from 1.29.0 to 1.29.1 (#1400) fix: return better error messages for grpc-gateway errors (#1397) fix: import for cockroach db (#1399) chore(deps): bump golang.org/x/tools from 0.6.0 to 0.7.0 in /_tools (#1394) chore: update readme w better usecase verbiage (#1395) fix(sdk/go): documentation and example corrections chore(deps): bump google.golang.org/protobuf from 1.28.1 to 1.29.0 (#1393) chore(deps): bump google.golang.org/protobuf in /_tools (#1391) chore(sdk/go): fix README markdown style fix(sdk/go): drop support for single field message mangling chore(sdk/go): add README chore(gowork): go edit -fmt feat(sdk/go): add doc.go feat(sdk/go): add static client token provider refactor(sdk/go): move grpc transport into its own subpackage ...
Currently, we return a very "go" specific type of error messaging when body inputs fail to unmarshal against the protobuf schema:
This error messaging does not really tell users what is going on with their inputs to the API, so this PR serves to change the error messaging to something like the following:
Fixes: FLI-129
Fixes: FLI-130