From aa478f1defbb727b942a5287bc450c3207534dcb Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 8 Nov 2022 15:12:52 +0300 Subject: [PATCH] [#2024] services/object: Unify status errors Signed-off-by: Evgenii Stratonikov --- CHANGELOG.md | 2 +- pkg/services/object/get/assemble.go | 2 +- pkg/services/object/get/util.go | 2 +- pkg/services/object/internal/client/client.go | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dfded801..3e719b41b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ Changelog for NeoFS Node - `neofs-cli container nodes`'s output (#1991) - Increase error counter for write-cache flush errors (#1818) - Correctly select the shard for applying tree service operations (#1996) -- Do not panic with bad inputs for `GET_RANGE` (#2007) +- Do not panic and return correct errors for bad inputs in `GET_RANGE` (#2007, #2024) - Physical child object removal by GC (#1699) - Broadcasting helper objects (#1972) - `neofs-cli lock object`'s `lifetime` flag handling (#1972) diff --git a/pkg/services/object/get/assemble.go b/pkg/services/object/get/assemble.go index 596a0bdb1..58cb95130 100644 --- a/pkg/services/object/get/assemble.go +++ b/pkg/services/object/get/assemble.go @@ -96,7 +96,7 @@ func (exec *execCtx) initFromChild(obj oid.ID) (prev *oid.ID, children []oid.ID) if seekTo < seekOff || parSize < seekOff || parSize < seekTo { var errOutOfRange apistatus.ObjectOutOfRange - exec.err = errOutOfRange + exec.err = &errOutOfRange exec.status = statusOutOfRange return diff --git a/pkg/services/object/get/util.go b/pkg/services/object/get/util.go index c1359c2d5..203fcc412 100644 --- a/pkg/services/object/get/util.go +++ b/pkg/services/object/get/util.go @@ -156,7 +156,7 @@ func (c *clientWrapper) getObject(exec *execCtx, info coreclient.NodeInfo) (*obj to := from + rng.GetLength() if pLen := uint64(len(payload)); to < from || pLen < from || pLen < to { - return nil, apistatus.ObjectOutOfRange{} + return nil, new(apistatus.ObjectOutOfRange) } return payloadOnlyObject(payload[from:to]), nil diff --git a/pkg/services/object/internal/client/client.go b/pkg/services/object/internal/client/client.go index 20e4c598f..c3d578114 100644 --- a/pkg/services/object/internal/client/client.go +++ b/pkg/services/object/internal/client/client.go @@ -330,7 +330,8 @@ const maxInitialBufferSize = 1024 * 1024 // 1 MiB // Returns: // // error of type *object.SplitInfoError if object raw flag is set and requested object is virtual; -// error of type *apistatus.ObjectAlreadyRemoved if the requested object is marked to be removed. +// error of type *apistatus.ObjectAlreadyRemoved if the requested object is marked to be removed; +// error of type *apistatus.ObjectOutOfRange if the requested range is too big. // // PayloadRange ignores the provided session if it is not related to the requested object. func PayloadRange(prm PayloadRangePrm) (*PayloadRangeRes, error) { @@ -359,7 +360,7 @@ func PayloadRange(prm PayloadRangePrm) (*PayloadRangeRes, error) { // `CopyN` expects `int64`, this check ensures that the result is positive. // On practice this means that we can return incorrect results for objects // with size > 8_388 Petabytes, this will be fixed later with support for streaming. - return nil, apistatus.ObjectOutOfRange{} + return nil, new(apistatus.ObjectOutOfRange) } ln := prm.ln