Skip to content

Comments

Protolib#3808

Open
cthulhu-rider wants to merge 2 commits intomasterfrom
protolib
Open

Protolib#3808
cthulhu-rider wants to merge 2 commits intomasterfrom
protolib

Conversation

@cthulhu-rider
Copy link
Contributor

@cthulhu-rider cthulhu-rider commented Feb 10, 2026

extracted from #3792

@codecov
Copy link

codecov bot commented Feb 10, 2026

Codecov Report

❌ Patch coverage is 84.98024% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 25.89%. Comparing base (5da5d4a) to head (1935f0b).
⚠️ Report is 29 commits behind head on master.

Files with missing lines Patch % Lines
internal/object/wire.go 56.62% 20 Missing and 16 partials ⚠️
internal/protobuf/errors.go 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3808      +/-   ##
==========================================
+ Coverage   25.48%   25.89%   +0.41%     
==========================================
  Files         668      673       +5     
  Lines       42848    43206     +358     
==========================================
+ Hits        10918    11189     +271     
- Misses      30929    30997      +68     
- Partials     1001     1020      +19     

☔ View full report in Codecov by Sentry.
📢 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 February 10, 2026 20:46
var prevNum protowire.Number
loop:
for {
num, typ, n, err := iprotobuf.ParseTag(buf[off:])
Copy link
Contributor

Choose a reason for hiding this comment

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

If len(buf)==0, here we have an error? Maybe we can do a check at the beginning of the function?

Copy link
Contributor Author

@cthulhu-rider cthulhu-rider Feb 13, 2026

Choose a reason for hiding this comment

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

i dont expect this to be called with empty buffer. If so, this is an error to me

Copy link
Member

Choose a reason for hiding this comment

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

This depends on use, if used by FSTree directly it can be problematic, empty buffer can appear as a result of a file read (touch fstree/a/b/c/dobj), erroring out is better than panic in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added check

@cthulhu-rider cthulhu-rider force-pushed the protolib branch 2 times, most recently from ac5c79e to 525df92 Compare February 16, 2026 07:36
fieldObjectHeader
fieldObjectPayload

FieldHeaderVersion = 1
Copy link
Member

Choose a reason for hiding this comment

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

Is there any way to avoid these redefinitions? Like some variable initialization in init() via https://pkg.go.dev/reflect#StructTag (SDK proto packages have this data) or some autogenerator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

they are declared in SDK, we can expose them. Codegen does not have them. Reflection is an overkill to me. So, const declaration is the easiest way to me now

Copy link
Member

Choose a reason for hiding this comment

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

Certainly we don't want another copy of this set. Then ideally it should be autogenerated in SDK as well, but that's a different story.

var prevNum protowire.Number
loop:
for {
num, typ, n, err := iprotobuf.ParseTag(buf[off:])
Copy link
Member

Choose a reason for hiding this comment

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

This depends on use, if used by FSTree directly it can be problematic, empty buffer can appear as a result of a file read (touch fstree/a/b/c/dobj), erroring out is better than panic in this case.

case FieldHeaderSplitParent:
idf, err = iprotobuf.ParseLENFieldBounds(buf, off, n, num, typ)
if err != nil {
return idf, sigf, hdrf, err
Copy link
Member

Choose a reason for hiding this comment

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

Parse first, switch/assign later, deduplicate this thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not all cases do the same. I prefer to leave as is

Copy link
Member

Choose a reason for hiding this comment

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

Parsing is all the same, that's just pure code duplication. Then switch/case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

return 0, 0, 0, err
}

if len(buf) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

BTW, this is checked, unlike GetNonPayloadFieldBounds.

TagBytes3 = 26
TagBytes4 = 34
TagBytes5 = 42
TagBytes6 = 50
Copy link
Member

Choose a reason for hiding this comment

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

Don't proto libraries have it in some form?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

they could be var _ = protowire.EncodeTag(n, protowire.BytesType), but they are constant essentially, i dont wanna have exported variables when possible

Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to autogen/autofill, but at the same time this isn't likely to change in any way. Maybe at least mention how it's created in comment or test it against EncodeTag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added test

Provide functionality which is going to be used for convenient protobuf
parsing. In particular, for #3783.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
Allows to work with object binary w/o full unmarshalling. Going to be
used in #3783.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
cthulhu-rider added a commit to nspcc-dev/neofs-sdk-go that referenced this pull request Feb 20, 2026
It turned out that field numbers are needed for flexible protobuf'ing,
as in nspcc-dev/neofs-node#3808.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
cthulhu-rider added a commit to nspcc-dev/neofs-sdk-go that referenced this pull request Feb 20, 2026
It turned out that field numbers are needed for flexible protobuf'ing,
as in nspcc-dev/neofs-node#3808.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
cthulhu-rider added a commit to nspcc-dev/neofs-sdk-go that referenced this pull request Feb 20, 2026
It turned out that field numbers are needed for flexible protobuf'ing,
as in nspcc-dev/neofs-node#3808.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
cthulhu-rider added a commit to nspcc-dev/neofs-sdk-go that referenced this pull request Feb 20, 2026
It turned out that field numbers are needed for flexible protobuf'ing,
as in nspcc-dev/neofs-node#3808.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
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