-
Notifications
You must be signed in to change notification settings - Fork 119
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
Specific response assertion error messages #547
Specific response assertion error messages #547
Conversation
1851450
to
bbc9d14
Compare
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.
Thanks! Looks good to me, with a minor change suggested. I wonder if it would be helpful to go one step further and say "expected x, got y" in these messages? But this is an improvement nonetheless.
envoyauth/response.go
Outdated
@@ -307,7 +307,7 @@ func (result *EvalResult) GetDynamicMetadata() (*_structpb.Struct, error) { | |||
|
|||
metadata, ok := val.(map[string]interface{}) | |||
if !ok { | |||
return nil, fmt.Errorf("type assertion error") | |||
return nil, fmt.Errorf("type assertion error, dynamic_metadata is not a map[string]interface{}") |
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.
map[string]interface{}
is a Go type, not a Rego one. I'd just say "is not an object" here. Same for headers below.
8ff459d
to
4a935df
Compare
I've updated the error messages to be "expected x, got y". Let me me know what you think :). |
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! @ashutosh-narkar ?
4a935df
to
c55648b
Compare
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.
@PietervdWerk the changes lgtm. It would be great if we can update the tests to reflect these detailed error messages.
@PietervdWerk this would be a good change to get in. Are you able to update the tests? |
Yes tomorrow! (I had a few days off, back to work tomorrow.) |
Signed-off-by: Pieter van der Werk <pieter.vdwerk@gmail.com>
Signed-off-by: Pieter van der Werk <pieter.vdwerk@gmail.com>
c969be8
to
33de40b
Compare
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.
Thanks @PietervdWerk!
I've been getting the error
"failed to get response body: type assertion error"
and it took me quite a while to figure out what the problem was. I've copied my policy into a playground and it worked fine there (in hindsight that's obvious).I propose a more verbose and specific error message when assertion fails. I've taken the liberty to come with some suggestions.