Apparently wrong type of CopyOptions.metadata
#2389
Labels
api: storage
Issues related to the googleapis/nodejs-storage API.
priority: p2
Moderately-important priority. Fix may not be included in next release.
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
It seems that the type of
CopyOptions.metadata
is wrong.Prior to #2234 (landed in f48dcd2),
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
The text was updated successfully, but these errors were encountered: