Closed mniewrzal closed 2 years ago
Change https://review.dev.storj.io/c/storj/common/+/7300 mentions this issue.
So I made a simple test case to check how request with empty or nil metadata will be unmarshaled and it looks there is no difference how nil
and []byte
is marshaled
request := &pb.ObjectBeginRequest{
EncryptedMetadata: []byte{},
}
data, err := pb.Marshal(request)
require.NoError(t, err)
var after pb.ObjectBeginRequest
err = pb.Unmarshal(data, &after)
require.NoError(t, err)
assert.Equal(t, []byte(nil), after.EncryptedMetadata)
request = &pb.ObjectBeginRequest{
EncryptedMetadata: nil,
}
data, err = pb.Marshal(request)
require.NoError(t, err)
err = pb.Unmarshal(data, &after)
require.NoError(t, err)
require.Equal(t, []byte(nil), after.EncryptedMetadata)
request = &pb.ObjectBeginRequest{
EncryptedMetadata: []byte{1},
}
data, err = pb.Marshal(request)
require.NoError(t, err)
err = pb.Unmarshal(data, &after)
require.NoError(t, err)
require.Equal(t, []byte{1}, after.EncryptedMetadata)
So for CommitObject to avoid overriding metadata we would need to add an additional flag like OverrideMetadata
.
Change https://review.dev.storj.io/c/storj/storj/+/7308 mentions this issue.
Change https://review.dev.storj.io/c/storj/storj/+/7301 mentions this issue.
Change https://review.dev.storj.io/c/storj/common/+/7366 mentions this issue.
For now, CommitObject will always get metadata from gateway (merged user metadata with etag) so we don't need to modify anything else for now.
User metadata is accepted only with CommitObject request. We would like to do this also at the beginning of upload. The main motivation is integration with gateway where while MPU metadata is provided only at the beginning. On metainfo side we need to update protobuf definition for begin object request and write it up with endpoint method. Metabase is already accepting metadata while begin object.
Acceptance Criteria:
secondary
from encrypted metadata fields (ObjectBeginRequest
)metainfo.BeginObject
method should use provided metadata fields and pass it to metabase.