Skip to content
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

NullReferenceException thrown during context.AddError when failing to CompleteCompositeType #961

Closed
tunurgitr opened this issue Aug 6, 2019 · 3 comments · Fixed by #979
Assignees
Milestone

Comments

@tunurgitr
Copy link
Contributor

Describe the bug
When executing a query with a schema defined by an interface with implementations registered, an error is thrown within the error reporting infrastructure.

To Reproduce
Steps to reproduce the behavior:

  1. Define a code-first interface, but don't add the implementation types
  2. Try to do a query that maps these interfaces

Expected behavior
A helpful error would be thrown indicating there was a problem mapping the CLR class to a registered type.

Additional context
https://github.com/ChilliCream/hotchocolate/blob/89b0a5d97a500e7fd6d16856987e417f524c6e42/src/Core/Core/Execution/Utilities/ValueCompletion.cs#L179

context.Value is null. Seems like it should be using the name of type.

image

@michaelstaib michaelstaib added this to the 10.0.0 milestone Aug 6, 2019
@michaelstaib michaelstaib self-assigned this Aug 6, 2019
@michaelstaib
Copy link
Member

I think the main issue here is that we create the schema in the first place since it is inconsistent.... let me check the spec first.

@michaelstaib
Copy link
Member

OK, this is now fixed.

@michaelstaib
Copy link
Member

So,

I have fixed also the execution engine code .... the context.Value was wrong in any way since that is the coerced output value. The type should be extracted from the result argument.

But I also added more context here.... the new error message is:

Could not resolve the actual object type from `System.String` for the abstract type `Bar`.

Apart from that the schema now validates interfaces more strict.

If you are in porto typing mode you can opt-out of the strictness with

SchemaBuilder
     ....
     .ModifyOption(o => o.StrictValidation = false)
     .Create()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants