Skip to content

Url signing breaks if metadata field has null #1598

@Agrumas

Description

@Agrumas

I tried to create signed url with null in one of metafield and it breaks in an unexpected way:

TypeError: Cannot read property 'split' of undefined
    at Request.signedUrlSigner (app\node_modules\aws-sdk\lib\signers\presign.js:62:42)
    at Request.callListeners (app\node_modules\aws-sdk\lib\sequential_executor.js:105:20)
    at callNextListener (app\node_modules\aws-sdk\lib\sequential_executor.js:95:12)
    at app\node_modules\aws-sdk\lib\event_listeners.js:207:9
    at finish (app\node_modules\aws-sdk\lib\config.js:315:7)
    at getStaticCredentials (app\node_modules\aws-sdk\lib\config.js:342:7)
    at Config.getCredentials (app\node_modules\aws-sdk\lib\config.js:349:9)
    at Request.SIGN (app\node_modules\aws-sdk\lib\event_listeners.js:179:22)
    at Request.callListeners (app\node_modules\aws-sdk\lib\sequential_executor.js:101:18)
    at Request.emit (app\node_modules\aws-sdk\lib\sequential_executor.js:77:10)
  message: 'Cannot read property \'split\' of undefined',
  code: 'TypeError',
  time: 2017-06-26T13:17:28.344Z,
  retryDelay: 33.933526783304345

Example:

const S3 = require('aws-sdk/clients/s3');
const s3 = new S3({
  region: 'eu-central-1',
  signatureVersion: 'v4',
  credentials: {accessKeyId: 'accessKeyId', secretAccessKey: 'secretAccessKey'}
});

s3.getSignedUrl('putObject', {
  Metadata: {userId: null},
  Bucket: 'test',
  Key: 'test-key',
  ACL: 'authenticated-read',
  Expires: 3600,
}, (error, data) => {
  console.log(error, data);
});

Most likely this situation is the same as reported in #834

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