diff --git a/federationapi/routing/backfill.go b/federationapi/routing/backfill.go index 7092c4364..69addcce6 100644 --- a/federationapi/routing/backfill.go +++ b/federationapi/routing/backfill.go @@ -73,7 +73,10 @@ func Backfill( } if req.Limit, err = strconv.Atoi(limit); err != nil { util.GetLogger(httpReq.Context()).WithError(err).Error("strconv.Atoi failed") - return jsonerror.InternalServerError() + return util.JSONResponse{ + Code: http.StatusBadRequest, + JSON: jsonerror.InvalidArgumentValue("limit is invalid format"), + } } // Query the roomserver. diff --git a/federationapi/routing/profile.go b/federationapi/routing/profile.go index 01a70c01b..42fe642ce 100644 --- a/federationapi/routing/profile.go +++ b/federationapi/routing/profile.go @@ -46,12 +46,17 @@ func GetProfile( _, domain, err := gomatrixserverlib.SplitID('@', userID) if err != nil { util.GetLogger(httpReq.Context()).WithError(err).Error("gomatrixserverlib.SplitID failed") - return jsonerror.InternalServerError() + return util.JSONResponse{ + Code: http.StatusBadRequest, + JSON: jsonerror.MissingArgument("Format of user ID is invalid."), + } } if domain != cfg.Matrix.ServerName { - util.GetLogger(httpReq.Context()).WithError(err).Error("domain != cfg.Matrix.ServerName failed") - return jsonerror.InternalServerError() + return util.JSONResponse{ + Code: http.StatusBadRequest, + JSON: jsonerror.InvalidArgumentValue("Domain does not match this server."), + } } profile, err := appserviceAPI.RetrieveUserProfile(httpReq.Context(), userID, asAPI, accountDB)