wire-api-federation-0.1.0: The Wire server-to-server API for federation
Safe HaskellSafe-Inferred
LanguageGHC2021

Wire.API.Federation.Error

Description

Map federation errors to client-facing errors.

This module contains most of the error-mapping logic that turns the various possible errors that can occur while making a federated request into errors that are meaningful for the clients.

There are three types of errors, from lowest level to highest:

  • FederatorClientHTTP2Error: this is thrown when something fails while connecting or making a request to the local federator.
  • FederatorClientError: this is the most common type of error, corresponding to a failure at the level of the federator client. It includes, for example, a failure to reach a remote federator, or an error on the remote side.
  • FederationError: this is created by users of the federator client. It can either wrap a FederatorClientError, or be an error that is outside the scope of the client, such as when a federated request succeeds with an unexpected result.

A general federated request is normally performed as a chain of HTTP requests (some of which are HTTP2). Errors can occur at each node of the chain, as well as in the communication between two adjacent nodes. A successful request goes through the following stages:

1) a service (say brig) makes a request to (the outward service of) the local federator (HTTP2); 2) the local federator processes this request; 3) the local federator makes a request to (the inward service of) a remote one (HTTP2); 4) the remote federator processes this request; 5) from the remote federator to a service on that backend (HTTP); 6) the remote service processes this request.

Failures at step 1 in the chain result in FederatorClientHTTP2Error, while any other failure results in a FederatorClientError.

Immediate failures in the outward service of a federator (stage 2) result in a 403 status code being returned to the federator client, which is then translated into an error with label federation-local-error.

Failures which occurred while making a request to a remote federator (stages 3 to 6) are turned into 5xx errors by federator itself, and then passed on through without any further mapping. This includes issues in stage 4, which are seen by the local federator as 403 status codes returned by the remote, as well as arbitrary error codes returned by a service.

Note that the federation API follows the convention that any error should be returned as part of a successful response with status code 200. Therefore any error response from services during a federated call should be considered a bug in the implementation of the federation API, and is therefore wrapped in a 533.

Synopsis

Federation errors

data FederatorClientError Source #

Possible errors resulting from a use of the federator client.

Constructors

FederatorClientHTTP2Error FederatorClientHTTP2Error

An error that occurred when establishing a connection to or communicating with the local federator.

FederatorClientStreamingNotSupported

Federator client does not currently support streaming, so this error will be thrown when using federator client to call APIs that contain a streaming body.

FederatorClientServantError ClientError

This error will be thrown when the response received from federator cannot be parsed by the servant machinery (e.g. its content type is malformed or unsupported).

FederatorClientError Error

This error will be thrown when federator returns an error response.

FederatorClientVersionNegotiationError VersionNegotiationError

This happens when an invalid version information response is returned by federator, or when negotiation fails because no common version could be found.

FederatorClientVersionMismatch

This happens when no endpoint for the negotiated version could be found among the alternative. This error could in principle be checked statically, but it is not trivial to do so.

data FederationError Source #

High level federation errors. When something goes wrong during a federated call, this error type should be used to represent the failure that occurred.

Note that federator client itself can only throw errors of type FederatorClientError, corresponding to the FederationCallFailure constructor of FederationError.

Constructors

FederationNotImplemented

To be used by endpoints to signal federation code paths that haven't been fully implemented yet.

FederationNotConfigured

No federator endpoint has been set, so no call to federator client can be made.

FederationCallFailure FederatorClientError

An error occurred while invoking federator client (see FederatorClientError for more details).

FederationUnexpectedBody Text

Federator client was invoked successfully, but the returned value is incorrect. For example, if a single conversation was requested from the remote backend, but multiple conversations have been returned. This can indicate a bug in either backend, or an incompatibility in the server-to-server API.

FederationUnexpectedError Text

Federator client got an unexpected error response from remote backend. Also used for error conditions that will go away in a future release, like "can't delete remote domains from config file", which is only needed until we start disregarding the config file.

Error status codes