Skip to content

gateway: proxy downstream service errors #3019

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

Merged
merged 2 commits into from
Jul 9, 2019

Conversation

evans
Copy link
Contributor

@evans evans commented Jul 9, 2019

In the gateway, we currently squash all errors from a single service
into a single Error with a generic message, such as Error while fetching subquery from service "registry". In other words, the gateway
globally overwrites errors from the underlying services and the original
errors are appended to Error.extensions.downstreamErrors.

This changes to behavior, so that the errors are proxied in their same
form rather than nested into a single error. Ultimately the underlying
services are better equipped than the gateway to expose/mask their own
errors with formatErrors and this removes the gateway as the
bottleneck of configuration. The original desire with the message mask
was to retain service info / context. To accomplish this, we add the
serviceName to the Error.extensions object for each. so users can
investigate the results.

@evans evans requested review from jbaxleyiii, abernix and trevor-scheer and removed request for jbaxleyiii and abernix July 9, 2019 20:55
@evans evans changed the base branch from master to release-gateway-6.13 July 9, 2019 22:00
evans added 2 commits July 9, 2019 15:01

Unverified

This user has not yet uploaded their public signing key.
In the gateway, we currently squash all errors from a single service
into a single `Error` with a generic message, such as `Error while
fetching subquery from service "registry"`. In other words, the gateway
globally overwrites errors from the underlying services and the original
errors are appended to `Error.extensions.downstreamErrors`.

https://github.com/apollographql/apollo-server/blob/9208e14ba1b96aea663f101e1089b40ca17790c2/packages/apollo-gateway/src/executeQueryPlan.ts#L242

This changes to behavior, so that the errors are proxied in their same
form rather than nested into a single error. Ultimately the underlying
services are better equipped than the gateway to expose/mask their own
errors with `formatErrors` and this removes the gateway as the
bottleneck of configuration. The original desire with the message mask
was to retain service info / context. To accomplish this, we add the
`serviceName` to the `Error.extensions` object for each. so users can
investigate the results.

Unverified

This user has not yet uploaded their public signing key.
@evans evans force-pushed the evans/unmask-gateway-errors branch from 78d2eb5 to d5e5cff Compare July 9, 2019 22:01
@evans evans merged commit dc2af9c into release-gateway-6.13 Jul 9, 2019
@evans evans deleted the evans/unmask-gateway-errors branch July 9, 2019 22:07
@glasser
Copy link
Member

glasser commented Jul 26, 2019

Hmm. I certainly like the overall idea of not burying the real errors. However, this now means that the gateway can (will!) return errors with a path that doesn't correspond to anything in the original user's request. How do we feel about that? Will that be confusing to human users? Does any tooling anywhere rely on the idea that error paths correspond to paths in the request/response?

@glasser
Copy link
Member

glasser commented Jul 26, 2019

(Perhaps these errors should lack a path and should instead put the path in an extension? Or maybe the behavior should be different for FetchNodes under FlattenNodes than those that are not?)

abernix pushed a commit to apollographql/federation that referenced this pull request Sep 4, 2020
…#3019)

* gateway: proxy downstream service errors

In the gateway, we currently squash all errors from a single service
into a single `Error` with a generic message, such as `Error while
fetching subquery from service "registry"`. In other words, the gateway
globally overwrites errors from the underlying services and the original
errors are appended to `Error.extensions.downstreamErrors`.

https://github.com/apollographql/apollo-server/blob/e849670ffe9e66ad05099aa6b9e9daeea055d489/packages/apollo-gateway/src/executeQueryPlan.ts#L242

This changes to behavior, so that the errors are proxied in their same
form rather than nested into a single error. Ultimately the underlying
services are better equipped than the gateway to expose/mask their own
errors with `formatErrors` and this removes the gateway as the
bottleneck of configuration. The original desire with the message mask
was to retain service info / context. To accomplish this, we add the
`serviceName` to the `Error.extensions` object for each. so users can
investigate the results.

* gateway: update changelog

Apollo-Orig-Commit-AS: apollographql/apollo-server@dc2af9c
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants