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

apollo-engine-reporting doesn't put errors associated with list elements on the right node #4476

Closed
glasser opened this issue Aug 12, 2020 · 2 comments · Fixed by #7699
Closed

Comments

@glasser
Copy link
Member

glasser commented Aug 12, 2020

This else path in treeBuilder.ts:

      const specificNode = this.nodes.get(path.join('.'));
      if (specificNode) {
        node = specificNode;
      } else {
        this.logger.warn(
          `Could not find node with path ${path.join(
            '.',
          )}; defaulting to put errors on root node.`,

is supposed to be a "can't happen" case, but it can happen. Nodes are added to this.nodes by willResolveField. There's no specific callback that adds list elements to this.nodes; they get there when some field below them is resolved. But if an error occurs associated with (by err.path) a list element rather than a field, the list element won't have a node and this path is triggered, spewing a warning and losing the correct location for the error.

This was reported by a user, and by code inspection I believe that there are a lot of ways for errors to be generated with a path that ends in a list element:

  • a resolver can return a list containing a Promise that rejects
  • a resolver whose return type is [X!] can return a list containing null
  • a resolver whose return type is a list of union or interface elements can return a list containing an element that cannot be resolved to an appropriate object type

This list is nonexhaustive.

@glasser
Copy link
Member Author

glasser commented Aug 12, 2020

The fix is probably just to call newNode (converting the array to the ResponsePath linked list) from addProtobufError instead of redirecting to the root.

@github-actions
Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For general questions, we recommend using StackOverflow or our discord server.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant