Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
EricCrosson opened this issue Jan 3, 2021 · 3 comments · Fixed by #1969 or #1974
Closed
Assignees
Labels
bug This issue is a bug.

Comments

@EricCrosson
Copy link
Contributor

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 {}.

@EricCrosson EricCrosson added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 3, 2021
@trivikr trivikr self-assigned this Jan 5, 2021
@trivikr
Copy link
Member

trivikr commented Jan 29, 2021

Reopening this issue as it needs to be fixed in absence of configuration convertClassInstanceToMap added in #1969

@trivikr trivikr reopened this Jan 29, 2021
@trivikr trivikr removed the needs-triage This issue or PR still needs to be triaged. label Jan 29, 2021
@trivikr
Copy link
Member

trivikr commented Jan 29, 2021

Using Object.entries() on an object created via Object.create() results in an empty array being returned. The code to convert object needs to be modified.

The AWS SDK for JavaScript (v2) uses for..in loop https://github.com/aws/aws-sdk-js/blob/2acf058fdb4f5a4c6fa1761c34c0b9ea10faa25c/lib/dynamodb/converter.js#L234

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug.
Projects
None yet
2 participants