Skip to content

putObject() with an empty stream fail #1436

@alxndrsn

Description

@alxndrsn

Observed

const filePath = './zero.bin';
fs.writeFileSync(filePath, '');
await minioClient.putObject(bucketName, 'zero.bin', fs.createReadStream(filePath));

Sends the following XML to minio server:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<CompleteMultipartUpload xmlns="http://s3.amazonaws.com/doc/2006-03-01/"/>

Returns

The error returned depends on the version of minio server used:

minio/minio:edge-cicd

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>MalformedXML</Code><Message>The XML you provided was not well-formed or did not validate against our published schema.</Message><Key>zero.bin</Key><BucketName>odk-central-bucket</BucketName><Resource>/odk-central-bucket/zero.bin</Resource><RequestId>18791B332D11C5FB</RequestId><HostId>6058d206-cc92-4caa-8c61-1cf42bb3b207</HostId></Error>

Which is thrown in Javascript as:

S3Error: The XML you provided was not well-formed or did not validate against our published schema.
    at parseError (node_modules/minio/dist/main/internal/xml-parser.js:59:13)
    at Object.parseResponseError (node_modules/minio/dist/main/internal/xml-parser.js:106:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Client.makeRequestStreamAsync (node_modules/minio/dist/main/internal/client.js:514:19)
    at async Client.completeMultipartUpload (node_modules/minio/dist/main/internal/client.js:1213:17)
    at async node_modules/minio/dist/main/internal/client.js:1510:14
    at async Promise.all (index 1)
    at async Client.uploadStream (node_modules/minio/dist/main/internal/client.js:1464:20)
    at async s3-demo-bugs.js:39:3 {
  code: 'MalformedXML',
  key: 'zero.bin',
  bucketname: 'odk-central-bucket',
  resource: '/odk-central-bucket/zero.bin',
  requestid: '18791B332D11C5FB',
  hostid: '6058d206-cc92-4caa-8c61-1cf42bb3b207',
  amzRequestid: '18791B332D11C5FB',
  amzId2: undefined,
  amzBucketRegion: undefined
}

minio/minio:latest

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidRequest</Code><Message>You must specify at least one part</Message><Key>zero.bin</Key><BucketName>odk-central-bucket</BucketName><Resource>/odk-central-bucket/zero.bin</Resource><RequestId>18795842B1D5F5DD</RequestId><HostId>dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8</HostId></Error>

Expected

I'd expect it to work, similar the following:

const filePath = './zero.bin';
fs.writeFileSync(filePath, '');
await minioClient.fPutObject(bucketName, 'zero.bin', filePath, metadata);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions