router icon indicating copy to clipboard operation
router copied to clipboard

Error handling audit

Open BrynCooke opened this issue 3 years ago • 6 comments

Create a comprehensive list of all errors. Ensure that error messages have:

  1. Information about what happened in a user friendly language.
  2. Information about what to do about the error in user friendly language.

Sensitive information must not be leaked. Consider metrics for infrastructure errors.

BrynCooke avatar Jul 06 '21 18:07 BrynCooke

putting that in the api-1.0 effort, although I think it's mostly done?

Geal avatar Jul 08 '22 08:07 Geal

Not sure if it belongs in here, but error handling in native plugins is pretty cumbersome as well. Is there an issue tracking this specifically?

o0Ignition0o avatar Jul 25 '22 06:07 o0Ignition0o

@o0Ignition0o I don't think there is an issue for that (at least not that I'm aware of)

abernix avatar Jul 26 '22 17:07 abernix

https://github.com/apollographql/router/pull/1487 make some error enums private, but the remaining ones are still in need of an audit. I think some variants are not used anymore. And the enums should probably be made #[non_exhaustive] so we can add variants after 1.0.

SimonSapin avatar Aug 11 '22 12:08 SimonSapin

In the spirit of https://github.com/apollographql/router/issues/1142#issuecomment-1211874799, we generally want to use a Vec<apollo_router::graphql::Error> in SomethingResponse value, rather than return Result::Err in Tower services.

~~What if we never used Result::Err, and make the error type std::convert::Infallible (an empty enum, impossible to construct) instead of BoxError?~~

SimonSapin avatar Aug 11 '22 12:08 SimonSapin

make the error type std::convert::Infallible

Let’s… not. tower::Buffer uses BoxError, tower_test::Mock uses BoxError. Building types from the http crate is fallible. and And probably more constraints I haven’t found yet

SimonSapin avatar Aug 11 '22 13:08 SimonSapin

If we wish to improve the quality of our generated error documentation:

In case you want to have an independent doc comment, the #[displaydoc("...") atrribute may be used on the variant or struct to override it.

We could use this mechanism to, for instance, number all of our errors: e.g.: router000001, etc...

garypen avatar Aug 18 '22 14:08 garypen

https://github.com/apollographql/router/pull/1621 completes the audit of error-handling-related Rust APIs for 1.0. Removing the label and milestone, but leaving this issue open as in 1.x we’ll want to audit the presentation / formatting of errors in GraphQL responses and in logs, as well as maybe add error codes.

SimonSapin avatar Aug 25 '22 17:08 SimonSapin