Closed anantakrishna closed 2 months ago
Thanks @anantakrishna we will take a look and see about getting it fixed up.
Thanks. Just in case, here are related changes: https://github.com/googleapis/nodejs-storage/pull/1406, https://github.com/googleapis/nodejs-storage/pull/1426.
There are a couple of issues here:
I am not sure whether CopyOptions.metadata
tyope should be reverted, I raised a PR but will await @ddelgrosso1 to reassert. I do think it should be changed though for neatness.
For the repro provided, I can validate that the nested metadata is indeed sent on request stream, but the backend seems to be ignoring (because it's nested?). There are a few approaches for end users here, but the library should not be doing either of these:
We discussed offline but putting here for visibility as well. Yes, CopyOptions.metadata
should be reverted. It should not be of type FileMetadata
. CopyOptions
was meant to represent editable metadata and I missed this during my previous changes.
This point should become moot if we change it back to the correct typing.
It seems that the type of
CopyOptions.metadata
is wrong.Prior to https://github.com/googleapis/nodejs-storage/pull/2234 (landed in f48dcd2d00081aea8990f35b68a91248f3862abe),
CopyOptions.metadata
was of typeMetadata=any
: https://github.com/googleapis/nodejs-storage/pull/2234/files#diff-bc9705d0f7a567399044dfc66ccc82d4d9aa1cff116842a0094d54e463c9ecbcL313, https://github.com/googleapis/nodejs-storage/pull/2234/files#diff-dd08f09f3839e8051415914bfa81750cc0f28ae2d9b1d6b95eb87bb0efff2577L48. This fact indicates that this property refers to the custom metadata. Moreover,cacheControl
,contentType
and other known metadata properties are declared directly on theCopyOptions
interface.After that PR was merged,
CopyOptions.metadata
got typeFileMetadata
, which itself containscacheControl
,contentType
, as well as nestedmetadata
, which is essentially aRecord<string, string>
and means “custom metadata”.It seems to me that
CopyOptions.metadata
should be of typeRecord<string, string>
directly. This is confirmed by the code below.Steps to reproduce
The copied file gets the following metadata:
Content-Type: outer
contentType: inner
- note how a property ofFileMetadata.contentType
it became a custom metadata.custom1: outer
Whereas
custom2
is ignored.Environment details
@google-cloud/storage
version:7.7.0