diff --git a/federationsender/internal/perform.go b/federationsender/internal/perform.go index c3e25aacd..a56d70ca2 100644 --- a/federationsender/internal/perform.go +++ b/federationsender/internal/perform.go @@ -90,7 +90,6 @@ func (r *FederationSenderInternalAPI) PerformJoin( // If we reach here then we didn't complete a join for some reason. var httpErr gomatrix.HTTPError if ok := errors.As(lastErr, &httpErr); ok { - logrus.Infof("TYPE CAST LASTERR OK!") httpErr.Message = string(httpErr.Contents) response.LastError = &httpErr } else { diff --git a/federationsender/inthttp/client.go b/federationsender/inthttp/client.go index b3951c81f..13cf09a3b 100644 --- a/federationsender/inthttp/client.go +++ b/federationsender/inthttp/client.go @@ -87,7 +87,7 @@ func (h *httpFederationSenderInternalAPI) PerformJoin( if err != nil { response.LastError = &gomatrix.HTTPError{ Message: err.Error(), - Code: 599, // to distinguish from genuine 500 + Code: 0, WrappedError: err, } } diff --git a/roomserver/api/perform.go b/roomserver/api/perform.go index 191033396..5d8d88a5a 100644 --- a/roomserver/api/perform.go +++ b/roomserver/api/perform.go @@ -46,12 +46,13 @@ func (p *PerformError) JSONResponse() util.JSONResponse { JSON: jsonerror.Forbidden(p.Msg), } case PerformErrRemote: - code := p.RemoteCode - if code == 0 { - code = 500 + // if the code is 0 then something bad happened and it isn't + // a remote HTTP error being encapsulated, e.g network error to remote. + if p.RemoteCode == 0 { + return util.ErrorResponse(fmt.Errorf("%s", p.Msg)) } return util.JSONResponse{ - Code: code, + Code: p.RemoteCode, // TODO: Should we assert this is in fact JSON? E.g gjson parse? JSON: json.RawMessage(p.Msg), }