Skip to content

util-dynamodb convertToAddr function does not identify objects with null prototype #1861

@EricCrosson

Description

@EricCrosson

Describe the bug
A clear and concise description of what the bug is.

This line does not identify objects created with a null prototype (i.e. Object.create(null)) and thus tries to decode a null-prototype object as a scalar value, eventually throwing the following error:

{ 
  type: 'aws',
  err: TypeError: Cannot convert object to primitive value
      at convertToScalarAttr (/home/eric/workspace/stratos/node_modules/@aws-sdk/util-dynamodb/src/convertToAttr.ts:122:47)
      at Object.convertToAttr (/home/eric/workspace/stratos/node_modules/@aws-sdk/util-dynamodb/src/convertToAttr.ts:20:12)
      at Object.marshall (/home/eric/workspace/stratos/node_modules/@aws-sdk/util-dynamodb/src/marshall.ts:29:41)
      at /home/eric/workspace/stratos/aws/lib/src/dynamo.ts:241:30
      at MapSink.event (/home/eric/workspace/stratos/node_modules/most/lib/fusion/Map.js:71:22)
      at TapSink.event (/home/eric/workspace/stratos/node_modules/most/lib/combinator/transform.js:81:13)
      at MapSink.event (/home/eric/workspace/stratos/node_modules/most/lib/fusion/Map.js:71:13)
      at PropagateTask.runJust [as _run] (/home/eric/workspace/stratos/node_modules/most/lib/source/core.js:46:8)
      at PropagateTask.run (/home/eric/workspace/stratos/node_modules/most/lib/scheduler/PropagateTask.js:43:8)
      at ScheduledTask.run (/home/eric/workspace/stratos/node_modules/most/lib/scheduler/ScheduledTask.js:20:20)
}

SDK version number

Installed from source today, so > 3.1.0 (currently unpublished)

Is the issue in the browser/Node.js/ReactNative?
Node.js

Details of the browser/Node.js/ReactNative version
v14.15.3

To Reproduce (observed behavior)
Try to marshall an object created with Object.create(null)

Expected behavior
marshall should marshall null-prototype objects in exactly the same was as it marshalls objects created with {}.

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions