Skip to content

Deduplicate object request fields' handling#4007

Open
cthulhu-rider wants to merge 3 commits into
masterfrom
object-deduplicate-refs
Open

Deduplicate object request fields' handling#4007
cthulhu-rider wants to merge 3 commits into
masterfrom
object-deduplicate-refs

Conversation

@cthulhu-rider

Copy link
Copy Markdown
Contributor

No description provided.

@codecov

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.88235% with 252 lines in your changes missing coverage. Please review.
✅ Project coverage is 27.71%. Comparing base (6b61bea) to head (6e15806).

Files with missing lines Patch % Lines
pkg/services/object/server.go 15.26% 155 Missing and 6 partials ⚠️
pkg/services/object/common.go 35.00% 25 Missing and 14 partials ⚠️
pkg/services/object/acl/v2/service.go 48.07% 22 Missing and 5 partials ⚠️
pkg/services/object/get.go 0.00% 13 Missing and 1 partial ⚠️
pkg/services/object/util.go 0.00% 4 Missing ⚠️
cmd/neofs-node/object.go 0.00% 3 Missing ⚠️
pkg/services/object/acl/acl.go 0.00% 2 Missing ⚠️
pkg/services/object/util/prm.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4007      +/-   ##
==========================================
- Coverage   27.78%   27.71%   -0.07%     
==========================================
  Files         681      681              
  Lines       46797    46725      -72     
==========================================
- Hits        13001    12951      -50     
+ Misses      32557    32551       -6     
+ Partials     1239     1223      -16     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cthulhu-rider cthulhu-rider marked this pull request as ready for review June 3, 2026 15:01
Comment thread pkg/services/object/common.go Outdated
return code, nil
}

func checkRequiredObjectAddress(m *protorefs.Address) (cid.ID, oid.ID, string) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why returning string, not an error?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's written to status message which is of string type

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still string is confusing here and makes using this function unobvious (its declaration reads as error-free), in its essence it's exactly an error, let the caller deal with how it's stringified or not.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made error

// first object not defined, unexpected, do not attach any header
}
}
case *protoobject.SearchRequest:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why dont we have SearchV2Request there? it also has cID

@cthulhu-rider cthulhu-rider Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's never been there 🤷‍♂️
refs nspcc-dev/neofs-testcases#1327

}

func WithOID(v *oid.ID) Option {
func WithOID(v oid.ID) Option {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isnt it a separate change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it could be, but i decided to change everything related to CID/OID in one change

Comment thread pkg/services/object/acl/v2/service.go Outdated
return RequestInfo{}, user.ID{}, fmt.Errorf("invalid container ID: %w", err)
}

func (b Service) PutRequestToInfo(request *protoobject.PutRequest, initPart *protoobject.PutRequest_Body_Init, cID cid.ID, obj oid.ID) (RequestInfo, user.ID, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer cnr here, both cID and cnr were used previously, so some code has to be changed anyway and cnr is used in most of other places.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread pkg/services/object/common.go Outdated
return code, nil
}

func checkRequiredObjectAddress(m *protorefs.Address) (cid.ID, oid.ID, string) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still string is confusing here and makes using this function unobvious (its declaration reads as error-free), in its essence it's exactly an error, let the caller deal with how it's stringified or not.

Comment thread pkg/services/object/common.go Outdated
return cnr, obj, ""
}

func checkRequiredContainerID(m *protorefs.ContainerID) (cid.ID, string) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for other functions here, it's Go, "smth + error" is what everyone expects.

Comment thread pkg/services/object/server.go Outdated
if reqInfo, objOwner, err := s.reqInfoProc.PutRequestToInfo(req); err != nil {
part, ok := req.Body.GetObjectPart().(*protoobject.PutRequest_Body_Init_)
if !ok {
if err = ps.forwardRequest(req); err != nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as an idea, maybe it's worth moving init handling outside of the loop, currently it's not immediately clear why we're forwarding here.

Comment thread pkg/services/object/server.go Outdated
HeadRequestToInfo(*protoobject.HeadRequest, cid.ID, oid.ID, *protosession.SessionTokenV2, *sessionv2.Token, *protosession.SessionToken, *session.Object, *protoacl.BearerToken, *bearer.Token) (aclsvc.RequestInfo, error)
GetRequestToInfo(*protoobject.GetRequest, cid.ID, oid.ID, *protosession.SessionTokenV2, *sessionv2.Token, *protosession.SessionToken, *session.Object, *protoacl.BearerToken, *bearer.Token) (aclsvc.RequestInfo, error)
RangeRequestToInfo(*protoobject.GetRangeRequest, cid.ID, oid.ID, *protosession.SessionTokenV2, *sessionv2.Token, *protosession.SessionToken, *session.Object, *protoacl.BearerToken, *bearer.Token) (aclsvc.RequestInfo, error)
SearchV2RequestToInfo(*protoobject.SearchV2Request, cid.ID, *protosession.SessionTokenV2, *sessionv2.Token, *protosession.SessionToken, *session.Object, *protoacl.BearerToken, *bearer.Token) (aclsvc.RequestInfo, error)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like how we're mixing proto/non-proto here (technically they're duplicating) and the overall parameter count becomes bigger than desired. Can we at least avoid proto/non-proto in the same call?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread pkg/services/object/common.go Outdated

if meta.SessionTokenV2 != nil {
var token sessionv2.Token
if err := token.FromProtoMessage(meta.SessionTokenV2); err != nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means we're decoding tokens for all requests instead of taking the decoded one from cache, that's kinda regression.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@cthulhu-rider cthulhu-rider force-pushed the object-deduplicate-refs branch from 53ac095 to da26707 Compare June 10, 2026 16:22
Check once and reuse wherever needed.

Signed-off-by: cthulhurider <ctulhurider@gmail.com>
Stale since e4a034c.

Signed-off-by: cthulhurider <ctulhurider@gmail.com>
Check once and reuse wherever needed.

Signed-off-by: cthulhurider <ctulhurider@gmail.com>
@cthulhu-rider cthulhu-rider force-pushed the object-deduplicate-refs branch from da26707 to 6e15806 Compare June 10, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants