-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
more actionable federation errors for nil key field queries #3437
Conversation
Signed-off-by: Steve Coffman <steve@khanacademy.org>
Signed-off-by: Steve Coffman <steve@khanacademy.org>
plugin/federation/federation.gotpl
Outdated
} | ||
{{- if (ne $i $keyField.Field.LastIndex ) }} | ||
if m, ok = val.(map[string]interface{}); !ok { | ||
break | ||
// nested field value is not a map[string]interface | ||
return "", fmt.Errorf("%w for {{$entity.Name}} due to nested Keyfield not being map value", ErrTypeNotFound) |
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.
@clayne11 This is the one I am least confident if it is a good error message
b0fbf6d
to
bfaf7fc
Compare
Signed-off-by: Steve Coffman <steve@khanacademy.org>
bfaf7fc
to
d6b38cf
Compare
@@ -310,10 +313,15 @@ func (ec *executionContext) resolveManyEntities( | |||
{{- range $i, $field := .Field }} | |||
val, ok = m["{{.}}"] | |||
if !ok { | |||
entityResolverErrs = append(entityResolverErrs, | |||
fmt.Errorf("%w due to missing Key Field \"{{.}}\" for {{$entity.Name}}", ErrTypeNotFound)) | |||
break | |||
} | |||
{{- if (ne $i $keyField.Field.LastIndex ) }} |
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 am not very sure I understand what this code is doing here.
We only want to possibly skip suggesting this resolver if the current field index does not match the last index of the key field?
In #3029 @clayne11 altered the federation behavior, so that null values for key Fields would now also skip using the resolver (since it would never work). This was both a security and performance enhancement, as expensive safelisted queries with nil KeyField values could have been sent for no reason.
However, the error messages for this change were not very specific and as a result, were not very clearly actionable.
I think I correctly understand the cases and have added more specific error messages, but I would definitely appreciate confirmation from @clayne11 or @kanodia-parag or anyone else that I'm not subtly misleading people.
I am collecting entity resolution errors as it is valid for entities with multiple key fields to fail with some resolvers and then succeed with a different resolver.