diff --git a/refs/types.go b/refs/types.go index 6e014b79..cd7ba5d8 100644 --- a/refs/types.go +++ b/refs/types.go @@ -199,7 +199,9 @@ func (s *SubnetID) MarshalText() ([]byte, error) { } // UnmarshalText decodes SubnetID from the text according to NeoFS API V2 protocol: -// should be base-10 integer string format. +// should be base-10 integer string format with bitsize = 32. +// +// Returns strconv.ErrRange if integer overflows uint32. // // Must not be called on nil. // diff --git a/refs/types_test.go b/refs/types_test.go index 187a8432..52c6b80c 100644 --- a/refs/types_test.go +++ b/refs/types_test.go @@ -1,6 +1,7 @@ package refs_test import ( + "math" "strconv" "testing" @@ -47,4 +48,13 @@ func TestSubnetID_UnmarshalText(t *testing.T) { require.NoError(t, err) require.EqualValues(t, val, id.GetValue()) + + t.Run("uint32 overflow", func(t *testing.T) { + txt := strconv.FormatUint(math.MaxUint32+1, 10) + + var id refs.SubnetID + + err := id.UnmarshalText([]byte(txt)) + require.ErrorIs(t, err, strconv.ErrRange) + }) }