You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ociregistry: breaking change: improve errors with respect to HTTP status
Currently the standard wire representation of an error is duplicated
across both client and server, and there is no way for:
- a client to access the actual HTTP status of a response
- an `Interface` implementation to cause the `ociserver` to return
a specific HTTP error status for an error code that it doesn't know
about.
This change addresses that by moving the wire representation into the
top level `ociregistry` package, splitting `HTTPError` into its own
type, and making both `ociclient` and `ociserver` aware of them.
One deliberate decision made here guards against some scenarios when
nesting an `ociclient` implementation inside `ociserver`. There is a
risk that, due to the fact we're using the same `HTTPError` in
`httpclient` and `httpserve, if `ociclient` talks to a misbehaving
server that returns inappropriate HTTP response codes, those codes could
propagate back through `ociserver`, causing that to return inappropriate
codes too.
So in `ociserver` we only use the `HTTPError` code if there is no known
HTTP status for the error code. This seems like a reasonable
half-way-house compromise.
We also change the `ociregistry.Error` interface so that `Detail` returns
`json.RawMessage` instead of `any`. This means that the error detail
is consistent no matter if the error has come from `ociclient` or from
a Go-implemented `ociregistry.Interface` implementation, and
means we can use `ociregistry.WireError` as the base error implementation
used by all the exported specific error values. This in turn means
that the error message changes because `WireError` includes the error
code (lower-cased) in the message, but that consistency seems like a
good thing.
Fixes#26.
Signed-off-by: Roger Peppe <[email protected]>
Change-Id: I5a79c1c6fec9f22c1f565830d73486b406dd181d
Reviewed-on: https://review.gerrithub.io/c/cue-labs/oci/+/1186153
Reviewed-by: Tianon Gravi <[email protected]>
TryBot-Result: CUE porcuepine <[email protected]>
Reviewed-by: Paul Jolly <[email protected]>
0 commit comments