Unexpected behaviour of searchV2 #1380

Closed
opened 2025-12-28 17:22:47 +00:00 by sami · 6 comments
Owner

Originally created by @tatiana-nspcc on GitHub (Mar 14, 2025).

Originally assigned to: @cthulhu-rider on GitHub.

I have a piece of code (below) that seems like it should work, but it isn't.

Current Behavior

It returns an error: "rpc failure: rpc error: code = Internal desc = grpc: error while marshaling: string field contains invalid UTF-8."

Expected Behavior

I wish this worked, or at least there was some description in the documentation explaining why it's wrong.

Steps to Reproduce

        filters := object.NewSearchFilters()
	filters.AddObjectOwnerIDFilter(object.MatchStringEqual, owner)
	filters.AddFilter(attributeToken, tokenType, object.MatchStringEqual)

	attrs := []string{
		object.FilterOwnerID,
		object.AttributeTimestamp,
		attributeName,
	}

	objects, _, err := s.neoFS.SearchObjects(ctx, s.accessBoxCnrID, filters, attrs, "", s.serverSigner, client.SearchObjectsOptions{})

However, when I changed the order of filters and attributes accordingly:

        filters.AddFilter(attributeToken, tokenType, object.MatchStringEqual)
	filters.AddObjectOwnerIDFilter(object.MatchStringEqual, owner)

	attrs := []string{
		attributeToken,
		object.AttributeTimestamp,
		attributeName,
	}

it works.
I'd prefer the first filter to be by owner because there are many owners, whereas attributeToken can only have two possible values.

Context

I created objects in one container, each of them having an owner (set by SetOwner(uid)).

The attributeToken can have one of two values: attributeTokenS3 or attributeTokenSession, where:

const (
	attributeName          = "token-name"
	attributeToken         = "token"
	attributeTokenS3       = "s3"
	attributeTokenSession  = "session"
)

Your Environment

  • Version of the product used: neofs-sdk-go@v1.0.0-rc.12.0.20250228085348-427e47be4cab
Originally created by @tatiana-nspcc on GitHub (Mar 14, 2025). Originally assigned to: @cthulhu-rider on GitHub. <!-- Provide a general summary of the issue in the Title above --> I have a piece of code (below) that seems like it should work, but it isn't. ## Current Behavior <!-- Tell us what happens instead of the expected behavior --> It returns an error: "rpc failure: rpc error: code = Internal desc = grpc: error while marshaling: string field contains invalid UTF-8." ## Expected Behavior <!-- Tell us what should happen --> I wish this worked, or at least there was some description in the documentation explaining why it's wrong. ## Steps to Reproduce <!-- Provide a link to a live example, or an unambiguous set of steps to reproduce this bug. --> ``` filters := object.NewSearchFilters() filters.AddObjectOwnerIDFilter(object.MatchStringEqual, owner) filters.AddFilter(attributeToken, tokenType, object.MatchStringEqual) attrs := []string{ object.FilterOwnerID, object.AttributeTimestamp, attributeName, } objects, _, err := s.neoFS.SearchObjects(ctx, s.accessBoxCnrID, filters, attrs, "", s.serverSigner, client.SearchObjectsOptions{}) ``` However, when I changed the order of filters and attributes accordingly: ``` filters.AddFilter(attributeToken, tokenType, object.MatchStringEqual) filters.AddObjectOwnerIDFilter(object.MatchStringEqual, owner) attrs := []string{ attributeToken, object.AttributeTimestamp, attributeName, } ``` it works. I'd prefer the first filter to be by owner because there are many owners, whereas `attributeToken` can only have two possible values. ## Context I created objects in one container, each of them having an owner (set by `SetOwner(uid)`). The `attributeToken` can have one of two values: `attributeTokenS3` or `attributeTokenSession`, where: ``` const ( attributeName = "token-name" attributeToken = "token" attributeTokenS3 = "s3" attributeTokenSession = "session" ) ``` ## Your Environment <!-- Include as many relevant details about the environment you experienced the bug in --> * Version of the product used: neofs-sdk-go@v1.0.0-rc.12.0.20250228085348-427e47be4cab
sami 2025-12-28 17:22:47 +00:00
  • closed this issue
  • added the
    bug
    U2
    S4
    I4
    labels
Author
Owner

@cthulhu-rider commented on GitHub (Mar 14, 2025):

@tatiana-nspcc may u pls share value of tokenType?

@cthulhu-rider commented on GitHub (Mar 14, 2025): @tatiana-nspcc may u pls share value of `tokenType`?
Author
Owner

@tatiana-nspcc commented on GitHub (Mar 14, 2025):

@tatiana-nspcc may u pls share value of tokenType?

one of two values: attributeTokenS3 or attributeTokenSession, or "s3" and "session"

@tatiana-nspcc commented on GitHub (Mar 14, 2025): > [@tatiana-nspcc](https://github.com/tatiana-nspcc) may u pls share value of `tokenType`? one of two values: attributeTokenS3 or attributeTokenSession, or "s3" and "session"
Author
Owner

@cthulhu-rider commented on GitHub (Mar 14, 2025):

reproduced. If client attaches invalid UTF-8 attribute:

rpc failure: rpc error: code = Internal desc = grpc: error while marshaling: string field contains invalid UTF-8

if server responds with it:

rpc failure: rpc error: code = Internal desc = grpc: error while marshaling: string field contains invalid UTF-8

so, now the user is unable to distinguish which side has a problem. The 1st thing coming to the mind is to pre-check user strings

@cthulhu-rider commented on GitHub (Mar 14, 2025): reproduced. If client attaches invalid UTF-8 attribute: ``` rpc failure: rpc error: code = Internal desc = grpc: error while marshaling: string field contains invalid UTF-8 ``` if server responds with it: ``` rpc failure: rpc error: code = Internal desc = grpc: error while marshaling: string field contains invalid UTF-8 ``` so, now the user is unable to distinguish which side has a problem. The 1st thing coming to the mind is to pre-check user strings
Author
Owner

@cthulhu-rider commented on GitHub (Mar 14, 2025):

i've made a quick patch https://github.com/nspcc-dev/neofs-sdk-go/tree/searchv2-utf8, and @tatiana-nspcc faced original error again. So, the problem is server-side. Comparing the non-working and working inputs, suspicion falls on the requested
object.FilterOwnerID. Will see

UPD: placing owner filter (and attribute) 1st causes the problem. This should help to reproduce for server debug

@cthulhu-rider commented on GitHub (Mar 14, 2025): i've made a quick patch https://github.com/nspcc-dev/neofs-sdk-go/tree/searchv2-utf8, and @tatiana-nspcc faced original error again. So, the problem is server-side. Comparing the non-working and working inputs, suspicion falls on the requested `object.FilterOwnerID`. Will see UPD: placing owner filter (and attribute) 1st causes the problem. This should help to reproduce for server debug
Author
Owner

@cthulhu-rider commented on GitHub (Mar 14, 2025):

reproduced in DevEnv:

$ neofs-cli object searchv2 -r s01.neofs.devenv:8080 --cid H761Gv5oWx7AsYab1j788ikYaBhxqbqhGzntWV6XX17C
Found 1 objects.
86QWb4bUmfmyQXPUh2iB74EWqVdo5iN66U48dTog6KnX

$ neofs-cli object head -r s01.neofs.devenv:8080 --cid H761Gv5oWx7AsYab1j788ikYaBhxqbqhGzntWV6XX17C --oid 86QWb4bUmfmyQXPUh2iB74EWqVdo5iN66U48dTog6KnX
ID: 86QWb4bUmfmyQXPUh2iB74EWqVdo5iN66U48dTog6KnX
CID: H761Gv5oWx7AsYab1j788ikYaBhxqbqhGzntWV6XX17C
Owner: NbUgTSFvPmsRxmGeWpuuGeJUoRoi6PErcM
CreatedAt: 40
Size: 4445
HomoHash: 719179512341ad9a3e5fc62225efd5cb45ec02dbe3cbb63a40fb7338c3d381d17f023adb9eddace0347c2713a1f22061423641a9c35fa758c8da0ad0aa8a3d1f
Checksum: 715b019d8949a7858f8b22b26807f4c19a11158a1a51b0889fc12b76b7d46b82
Type: REGULAR
Attributes:
  FileName=Makefile
  Timestamp=1741970550 (2025-03-14 19:42:30 +0300 MSK)
ID signature:
  public key: 03494980497ffb11e2705d3493113b132071eb03a198c48f1d7f37d2d43e8c147a
  signature: 04acf9d4f83fad6e2fb4eac0cd74d99c52579680e410130b976d4570c10a0147f1d5c0da3c4735dd913dcdaeb1698d9432679ff8fdc5701dcf2c35a72171198b0b

$ neofs-cli object searchv2 -r s01.neofs.devenv:8080 --cid H761Gv5oWx7AsYab1j788ikYaBhxqbqhGzntWV6XX17C --filters '$Object:ownerID EQ NbUgTSFvPmsRxmGeWpuuGeJUoRoi6PErcM'
Found 1 objects.
86QWb4bUmfmyQXPUh2iB74EWqVdo5iN66U48dTog6KnX

$ neofs-cli object searchv2 -r s01.neofs.devenv:8080 --cid H761Gv5oWx7AsYab1j788ikYaBhxqbqhGzntWV6XX17C --filters '$Object:ownerID EQ NbUgTSFvPmsRxmGeWpuuGeJUoRoi6PErcM' --attributes '$Object:ownerID'
rpc error: rpc failure: rpc error: code = Internal desc = grpc: error while marshaling: string field contains invalid UTF-8
@cthulhu-rider commented on GitHub (Mar 14, 2025): reproduced in DevEnv: ``` $ neofs-cli object searchv2 -r s01.neofs.devenv:8080 --cid H761Gv5oWx7AsYab1j788ikYaBhxqbqhGzntWV6XX17C Found 1 objects. 86QWb4bUmfmyQXPUh2iB74EWqVdo5iN66U48dTog6KnX $ neofs-cli object head -r s01.neofs.devenv:8080 --cid H761Gv5oWx7AsYab1j788ikYaBhxqbqhGzntWV6XX17C --oid 86QWb4bUmfmyQXPUh2iB74EWqVdo5iN66U48dTog6KnX ID: 86QWb4bUmfmyQXPUh2iB74EWqVdo5iN66U48dTog6KnX CID: H761Gv5oWx7AsYab1j788ikYaBhxqbqhGzntWV6XX17C Owner: NbUgTSFvPmsRxmGeWpuuGeJUoRoi6PErcM CreatedAt: 40 Size: 4445 HomoHash: 719179512341ad9a3e5fc62225efd5cb45ec02dbe3cbb63a40fb7338c3d381d17f023adb9eddace0347c2713a1f22061423641a9c35fa758c8da0ad0aa8a3d1f Checksum: 715b019d8949a7858f8b22b26807f4c19a11158a1a51b0889fc12b76b7d46b82 Type: REGULAR Attributes: FileName=Makefile Timestamp=1741970550 (2025-03-14 19:42:30 +0300 MSK) ID signature: public key: 03494980497ffb11e2705d3493113b132071eb03a198c48f1d7f37d2d43e8c147a signature: 04acf9d4f83fad6e2fb4eac0cd74d99c52579680e410130b976d4570c10a0147f1d5c0da3c4735dd913dcdaeb1698d9432679ff8fdc5701dcf2c35a72171198b0b $ neofs-cli object searchv2 -r s01.neofs.devenv:8080 --cid H761Gv5oWx7AsYab1j788ikYaBhxqbqhGzntWV6XX17C --filters '$Object:ownerID EQ NbUgTSFvPmsRxmGeWpuuGeJUoRoi6PErcM' Found 1 objects. 86QWb4bUmfmyQXPUh2iB74EWqVdo5iN66U48dTog6KnX $ neofs-cli object searchv2 -r s01.neofs.devenv:8080 --cid H761Gv5oWx7AsYab1j788ikYaBhxqbqhGzntWV6XX17C --filters '$Object:ownerID EQ NbUgTSFvPmsRxmGeWpuuGeJUoRoi6PErcM' --attributes '$Object:ownerID' rpc error: rpc failure: rpc error: code = Internal desc = grpc: error while marshaling: string field contains invalid UTF-8 ```
Author
Owner

@roman-khimov commented on GitHub (Mar 14, 2025):

Binary representation of owner/checksum and some other things can legitimately have zero bytes.

@roman-khimov commented on GitHub (Mar 14, 2025): Binary representation of owner/checksum and some other things can legitimately have zero bytes.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nspcc-dev/neofs-node#1380
No description provided.