serverless-dynamodb-local
serverless-dynamodb-local copied to clipboard
Null object properties not supported in seed
Actual Behaviour
Seed does not support objects with a top-level property that has a null value.
{ a: '1', b: null } does not work
{ a: '1', b: '2' } works
Note nested null values work ({ a: '1', b: { c: '2', d: null } } works)
Expected Behaviour
Seed objects should allow for the "null" value in a top-level property.
Steps to reproduce it
- Create a seed file with a null property (i.e.
{ a: '1', b: null }) - Run start with seed
- Crash with
cannot read property 'type' of nullerror
LogCat for the issue
$ sls dynamodb start --seed=dev
Dynamodb Local Started, Visit: http://localhost:8000/shell
Serverless: DynamoDB - created table test-db
Type Error ---------------------------------------------
Cannot read property 'type' of null
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Stack Trace --------------------------------------------
TypeError: Cannot read property 'type' of null
at ____\node_modules\serverless-dynamodb-local\src\seeder.js:100:14
at ____\node_modules\lodash\lodash.js:4925:15
at baseForOwn (____\node_modules\lodash\lodash.js:3010:24)
at ____\node_modules\lodash\lodash.js:4894:18
at Function.forEach (____\node_modules\lodash\lodash.js:9342:14)
at unmarshalBuffer (____\node_modules\serverless-dynamodb-local\src\seeder.js:98:5)
at arrayEach (____\node_modules\lodash\lodash.js:516:11)
at Function.forEach (____\node_modules\lodash\lodash.js:9342:14)
at getSeedsAtLocation (____\node_modules\serverless-dynamodb-local\src\seeder.js:120:14)
at fileExists.then (____\node_modules\serverless-dynamodb-local\src\seeder.js:140:14)
From previous event:
at PluginManager.invoke (%APPDATA%\npm\node_modules\serverless\lib\classes\PluginManager.js:368:22)
at PluginManager.run (%APPDATA%\npm\node_modules\serverless\lib\classes\PluginManager.js:399:17)
at variables.populateService.then (%APPDATA%\npm\node_modules\serverless\lib\Serverless.js:102:33)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
From previous event:
at Serverless.run (%APPDATA%\npm\node_modules\serverless\lib\Serverless.js:89:74)
at serverless.init.then (%APPDATA%\npm\node_modules\serverless\bin\serverless:42:50)
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Forums: forum.serverless.com
Chat: gitter.im/serverless/serverless
Your Environment Information -----------------------------
OS: win32
Node Version: 6.11.3
Serverless Version: 1.25.0
I removed local filesystem prefixes, ____ is the project directory
Screenshots of the issue
N/A
Would you like to work on the issue?
In src/seeder.js you should just be able to add a null check to the unmarshalBuffer function on line 99:
if (value !== null && value.type==="Buffer")
instead of
if (value.type==="Buffer")
I won't have time to work on it, but I know this works with the cases I have.
@mbruning24 I would like to work on the issue and have already fixed it, the only thing is that I want to introduce the fix as a feature. An issue that is related to the same is raised here #169 . The issue #169 will come when you add the condition above, I have fixed both issues in a configurable way. I have also mentioned the same on gitter. Let me know if I can work on this Thanks.