OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

DynamoDB / marshal function complains about an undefined value

  • Thread starter Thread starter Adam
  • Start date Start date
A

Adam

Guest
When I try to persist my JavaScript object to DynamoDB using the PutCommand, I am seeing the following error message:

Code:
Error: Pass options.removeUndefinedValues=true to remove undefined values from map/array/set.

This happens when I use DynamoDBDocumentClient

When I use DynamoDBClient then I must first marshal the object using marshall(..) from @aws-sdk/util-dynamodb. In this case the error is shown when I try to marshal the object.

When I print my object to the console, I don't see any undefined values. However, I don't see the complete object due to too many levels of nesting:

Code:
{ id: 123, child: { anotherChild: { nested: [Object] } } }

So instead I use JSON.stringify(..) to display the entire object:

Code:
{
    "id": 123,
    "child": {
        "anotherChild": {
            "nested": {
                "name": "Jane"
            }
        }
    }
}

I apparently don't have any undefined attributes, so why am I seeing the error message?

<p>When I try to persist my JavaScript object to DynamoDB using the <code>PutCommand</code>, I am seeing the following error message:</p>
<pre class="lang-plaintext prettyprint-override"><code>Error: Pass options.removeUndefinedValues=true to remove undefined values from map/array/set.
</code></pre>
<p>This happens when I use <code>DynamoDBDocumentClient</code></p>
<p>When I use <code>DynamoDBClient</code> then I must first marshal the object using <code>marshall(..)</code> from <code>@aws-sdk/util-dynamodb</code>. In this case the error is shown when I try to marshal the object.</p>
<p>When I print my object to the console, I don't see any undefined values. However, I don't see the complete object due to too many levels of nesting:</p>
<pre class="lang-js prettyprint-override"><code>{ id: 123, child: { anotherChild: { nested: [Object] } } }
</code></pre>
<p>So instead I use <code>JSON.stringify(..)</code> to display the entire object:</p>
<pre class="lang-js prettyprint-override"><code>{
"id": 123,
"child": {
"anotherChild": {
"nested": {
"name": "Jane"
}
}
}
}
</code></pre>
<p>I apparently don't have any undefined attributes, so why am I seeing the error message?</p>
 

Latest posts

Top