nodejs-storage icon indicating copy to clipboard operation
nodejs-storage copied to clipboard

Supplying a complex object (i.e. buffer) as an argument to md5Hash or crc32c does not invoke server validation

Open ddelgrosso1 opened this issue 2 years ago • 3 comments

In the course of investigating #1829 we discovered that if a complex object (buffer in the example) is provided as the argument to metadata.md5Hash or metadata.crc32c the server ignores the argument and does not perform server validation. The expectation in testing was that when invalid input was provided the server would return a 400 error complaining that the provided hash/checksum was not encoded correctly. If an invalid string is provided, an error is correctly returned.

ddelgrosso1 avatar Mar 31 '22 13:03 ddelgrosso1

TODO: look into this further after https://github.com/googleapis/gaxios/pull/475 is merged

shaffeeullah avatar Apr 06 '22 17:04 shaffeeullah

Reducing this to a p3 as when provided a string this works as expected.

ddelgrosso1 avatar Apr 29 '22 17:04 ddelgrosso1

Tagged as external because this is an issue with the gaxios dependency.

shaffeeullah avatar Aug 10 '22 14:08 shaffeeullah

Re-visiting this today I took a look at the JSON docs. Both MD5 and CRC32C are defined as strings. As such I do not think the library should handle the case of different types being supplied as the argument. This will also become more evident when we add stronger typings: https://github.com/googleapis/nodejs-storage/issues/1817. As a result I am going to close this out as I think the real work is captured there.

ddelgrosso1 avatar Feb 27 '23 20:02 ddelgrosso1