router
router copied to clipboard
Error handling audit
Create a comprehensive list of all errors. Ensure that error messages have:
- Information about what happened in a user friendly language.
- Information about what to do about the error in user friendly language.
Sensitive information must not be leaked. Consider metrics for infrastructure errors.
putting that in the api-1.0 effort, although I think it's mostly done?
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 I don't think there is an issue for that (at least not that I'm aware of)
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.
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
?~~
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
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...
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.