Comments: Add a Create Note API

Link to chapter - http://serverless-stack.com/chapters/add-a-create-note-api.html

The runtime line in the serverless.yml file should read:
runtime: nodejs6.10
Looks like you updated it for the prior page for Serverless 1.10's support of AWS/Node6 but missed this one.  Minor thing but thought you'd want to know.

Oh yeah you're right. Just fixed it - 87587868b0829ded83cfde2a00e7a5af8f441518

When testing the code, I'm getting a 500 response. How do I troubleshoot this?
The only thing I've done differently is change all instances of us-east-1 to us-east-2 to match values I see in my pool id, pool arn, identity pool id, etc. Seemed like the right thing to do.

@geirman that would be a DynamoDB related error. Can you try printing out the error object in this line - https://github.com/AnomalyInnovations/serverless-stack-com/blame/master/_chapters/add-a-create-note-api.md#L56
That should give you a clue.

Thanks, that helped. My problem was naming one of the keys notesId instead of noteId

ValidationException: One or more parameter values were invalid: Missing the key notesId in the item

Hello,
When I run the command : serverless webpack invoke --function create --path event.json
I have this :
{ statusCode: 500,
  headers:
   { 'Access-Control-Allow-Origin': '*',
     'Access-Control-Allow-Credentials': true },
  body: '{"status":false}' }

content of DynamoDB object :
      Config {
        credentials: null,
        credentialProvider: [Object],
        region: 'eu-west-2',
        logger: null,
        apiVersions: {},
        apiVersion: null,
        endpoint: 'dynamodb.eu-west-2.amazonaws.com',
        httpOptions: [Object],
        maxRetries: undefined,
        maxRedirects: 10,
        paramValidation: true,
        sslEnabled: true,
        s3ForcePathStyle: false,
        s3BucketEndpoint: false,
        s3DisableBodySigning: true,
        computeChecksums: true,
        convertResponseTypes: true,
        correctClockSkew: false,
        customUserAgent: null,
        dynamoDbCrc32: true,
        systemClockOffset: 0,
        signatureVersion: 'v4',
        signatureCache: true,
        retryDelayOptions: {},
        useAccelerateEndpoint: false },
     isGlobalEndpoint: false,
     endpoint:
      Endpoint {
        protocol: 'https:',
        host: 'dynamodb.eu-west-2.amazonaws.com',
        port: 443,
        hostname: 'dynamodb.eu-west-2.amazonaws.com',
        pathname: '/',
        path: '/',
        href: 'https://dynamodb.eu-west-2.amazonaws.com/' },
     _clientId: 1 },
  attrValue: 'S8' }

And the error is :
 CredentialsError: Missing credentials in config
    at ClientRequest.<anonymous> (/Users/flocve/Sites/labs/notes-app-api/node_modules/aws-sdk/lib/http/node.js:83:34)
    at ClientRequest.g (events.js:291:16)
    at emitNone (events.js:86:13)
    at ClientRequest.emit (events.js:185:7)
    at Socket.emitTimeout (_http_client.js:620:10)
    at Socket.g (events.js:291:16)
    at emitNone (events.js:86:13)
    at Socket.emit (events.js:185:7)
    at Socket._onTimeout (net.js:339:8)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)
  message: 'Missing credentials in config',
  code: 'CredentialsError',
  time: 2017-04-17T10:06:21.387Z,
  retryable: true,
  originalError:
   { message: 'Could not load credentials from any providers',
     code: 'CredentialsError',
     time: 2017-04-17T10:06:21.387Z,
     retryable: true,
     originalError:
      { message: 'Connection timed out after 1000ms',
        code: 'TimeoutError',
        time: 2017-04-17T10:06:21.386Z,
        retryable: true } } }

I Follow the tutorial (2 times :) ), but impossible to understand what is my problem.
I used the region eu-west-2 instead of us-east-1.
Did I forget something ?

@flocve Could you double check if these two files exist ~/.aws/config and ~/.aws/credentials
~/.aws/config should look like
[default]
region = eu-west-2

~/.aws/credentials should look like
[default]
aws_access_key_id = AKIXXXXGMPQAP123XXXX
aws_secret_access_key = JOsGrXxxXl8o8bXxXxbOf1RoDw2guXXxxXXxx123

Hello,
Following these steps, I have been getting an error on LAMBDA_PROXY function of api gateway.
the response on request also includes the:

   statusCode: 200,
    headers: {
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Credentials': true,
    },
    body: ....

and if a error (500) occur, the status code is 200.

@eliocapelati can you show me the full response that you are seeing?

Here a 404 error... I just changed the 500 to 404...

@eliocapelati I'm a bit confused here. According to your code you are throwing the 404 error. That is how it should work right? There is no problem then right?

I'm getting:
{ ResourceNotFoundException: Requested resource not found
at Request.extractError (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/protocol/json.js:48:27)
at Request.callListeners (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at Request.emit (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:673:14)
at Request.transition (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:675:12)
at Request.callListeners (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
at Request.emit (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:673:14)
at Request.transition (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/request.js:675:12)
at Request.callListeners (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
at callNextListener (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/sequential_executor.js:95:12)
at IncomingMessage.onEnd (/Users/dei/Dev-exploration/serverless-stack/notes-app-api/node_modules/aws-sdk/lib/event_listeners.js:254:11)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
message: 'Requested resource not found',
code: 'ResourceNotFoundException',
time: 2017-05-10T12:45:43.839Z,
requestId: '9AD2PP6137PVQV7O652HGL5JE3VV4KQNSO5AEMVJF66Q9ASUAAJG',
statusCode: 400,
retryable: false,
retryDelay: 15.609907065688 }

Same problem here @deivers

@deivers @vfonsecapv when are you seeing this error?

@ryanjcruz Glad you figured it out. Just noticed somebody else is having a similar issue as well.

serverless webpack invoke --function create --path event.json
Serverless: Bundling with Webpack...
Time: 1287ms
Asset Size Chunks Chunk Names
create.js 6.35 kB 0 [emitted] create
handler.js 2.28 kB 1 [emitted] handler
Serverless: Run function create...
{ statusCode: 500,
headers:
{ 'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': true },
body: '{"status":false}' }
When I invoke the create function I got the above error, I did everything as mentioned in the tutorial, I couldn't able to trace the error, kindly help me to resolve the issue.

When running serverless webpack invoke --function create --path event.json, I get the following:
Unexpected token import

Okay, I fixed this with:
npm install --save-dev babel-preset-es2015
And then, changed .babelrc file:
{
  "plugins": ["transform-runtime"],
  "presets": ["react-app","es2015"]
}

Hi, everyone. I need your help, please!!!
When I running   serverless webpack invoke --function create --path event.json the result is this:
**import _JSON$stringify from 'babel-runtime/core-js/json/stringify';**
^^^^^^

SyntaxError: Unexpected token import
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at ServerlessWebpack.loadHandler (/Users/sapo/Development/notes/notes-app-api/node_modules/serverless-webpack/lib/run.js:21:20)
at ServerlessWebpack.run (/Users/sapo/Development/notes/notes-app-api/node_modules/serverless-webpack/lib/run.js:61:26)
at ServerlessWebpack.tryCatcher (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:693:18)
at Promise._fulfill (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:638:18)
at Promise._resolveCallback (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:432:57)
at Promise._settlePromiseFromHandler (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:524:17)
at Promise._settlePromise (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:693:18)
at Promise._fulfill (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:638:18)
From previous event:
at PluginManager.invoke (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:234:22)
at PluginManager.run (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:253:17)
at variables.populateService.then (/usr/local/lib/node_modules/serverless/lib/Serverless.js:96:33)
From previous event:
at Serverless.run (/usr/local/lib/node_modules/serverless/lib/Serverless.js:87:74)
at serverless.init.then (/usr/local/lib/node_modules/serverless/bin/serverless:23:50)
Your Environment Information -----------------------------
OS:                 darwin
Node Version:       6.9.4
Serverless Version: 1.13.2
Thanks!!!

@go4cas That's weird, the react-app preset should handle that already. Can I see your package.json just to make sure things are okay?

@martinsaporiti this looks like the same issue as @go4cas. Let me check what is going on.

@martinsaporiti @go4cas You guys are right, there is an issue with the new react-app preset. I just updated the chapter with the proper presets - https://github.com/AnomalyInnovations/serverless-stack-com/commit/201c8818686650b67008d108b0aef047d8a59cec

Thanks @jayair and @go4cas ! Now work perfectly:
{ statusCode: 200,
  headers:
   { 'Access-Control-Allow-Origin': '*',
     'Access-Control-Allow-Credentials': true },
  body: '{"userId":"USER-SUB-1234","noteId":"b605af70-3e93-11e7-8117-312305557adf","content":"hello world","attachment":"hello.jpg","createdAt":1495418979303}' }

I will continue with the tutorial. It's very useful.
Thanks again!

@jayair I'm running into the same problem as @deivers and @vfonsecapv when I run the test with event.json. I do have multiple profiles and I'm not using the default profile in this case. I'm using us-west-2 and I believe I already changed that everywhere in the code. Any clue how I can debug?

nevermind, I figured it out. If you're not using your default profile then in your create.js you need to do
const credentials = new AWS.SharedIniFileCredentials({profile: 'profile_name'}); AWS.config.credentials = credentials;

@oliv9286 Thanks for reporting back. Are you setting this in the top of your create.js?

I also get the same error as @deivers  and @vfonsecapv .
When I run
./node_modules/serverless/bin/serverless webpack invoke --function create --path event.json
I get
Serverless: Run function create...
{ ResourceNotFoundException: Requested resource not found
at Request.extractError (/home/tjones/note-app-api/node_modules/aws-sdk/lib/protocol/json.js:48:27)
at Request.callListeners (/home/tjones/note-app-api/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at Request.emit (/home/tjones/note-app-api/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/home/tjones/note-app-api/node_modules/aws-sdk/lib/request.js:682:14)
at Request.transition (/home/tjones/note-app-api/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/home/tjones/note-app-api/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /home/tjones/note-app-api/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/home/tjones/note-app-api/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/home/tjones/note-app-api/node_modules/aws-sdk/lib/request.js:684:12)
at Request.callListeners (/home/tjones/note-app-api/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
at Request.emit (/home/tjones/note-app-api/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/home/tjones/note-app-api/node_modules/aws-sdk/lib/request.js:682:14)
at Request.transition (/home/tjones/note-app-api/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/home/tjones/note-app-api/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /home/tjones/note-app-api/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/home/tjones/note-app-api/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/home/tjones/note-app-api/node_modules/aws-sdk/lib/request.js:684:12)
at Request.callListeners (/home/tjones/note-app-api/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
at callNextListener (/home/tjones/note-app-api/node_modules/aws-sdk/lib/sequential_executor.js:95:12)
at IncomingMessage.onEnd (/home/tjones/note-app-api/node_modules/aws-sdk/lib/event_listeners.js:256:13)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
message: 'Requested resource not found',
code: 'ResourceNotFoundException',
Note that I didnt install the serverless module as global.
I do not have multiple profiles as @oliv9286 did.

@tobyjo can I take a look at your serverless.yml?

@fwang Sure, please find attached.
serverless.zip

@tobyjo I've had the same issue as you and my problem was that my DynamoDB table wasn't created when I thought I did. I would double-check in your AWS Console and see if your notes table was created.

@tobyjo A side note about your serverless.yml, this is not related to the error you are seeing. The authorizer arn in your serverless.yml should start with "arn:aws:cognito-idp:" and look something like " arn:aws:cognito-idp:us-east-1:232771856781:userpool/us-east-1_YExxXXxxx". You can get the User Pool arn from this chapter:
http://serverless-stack.com/chapters/create-a-cognito-user-pool.html
Back to the issue you were seeing, try @kevinnguy's suggestion.

@kevinnguy @fwang Thanks both. Have been distracted currently with other work but as soon as I get back to this I will let you know the results. Thanks again.

Any reason why I am receiving the error below?
serverless webpack invoke -f create -p mocks/create-event.json
/mnt/c/Users/cgrecea/AppData/Roaming/npm/node_modules/serverless/node_modules/bluebird/js/release/async.js:48
        fn = function () { throw arg; };
                           ^

ServerlessError: In the command you just typed, the "webpack" is valid but "invoke" is not.  Enter "serverless help" to see the actions for this context.
    at new ServerlessError (/mnt/c/Users/cgrecea/AppData/Roaming/npm/node_modules/serverless/lib/ServerlessError.js:17:11)

@copperspeed Can you make sure you've added serverless-webpack to your project? We do this in the Install Babel and Webpack step of this chapter http://serverless-stack.com/chapters/add-support-for-es6-es7-javascript.html.

@jayair  yes, I have serverless-webpack installed.
devDependencies": {
    "aws-sdk": "^2.72.0",
    "babel-core": "^6.25.0",
    "babel-loader": "^7.0.0",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-stage-3": "^6.24.1",
    "glob": "^7.1.2",
    "serverless-webpack": "^1.0.0-rc.4",
    "webpack": "^2.6.1",
    "webpack-node-externals": "^1.6.0"
  },
  "dependencies": {
    "babel-runtime": "^6.23.0",
    "uuid": "^3.1.0"
  }

Ok, my issue was do to forgetting to install Serverless. Duh!!! lol

This weekend I got through the whole example without any problems, today I get the error:
ERROR in Entry module not found: Error: Can't resolve 'babel' in 'C:\projects\happyToHelp\backend'
BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.
You need to specify 'babel-loader' instead of 'babel',
see https://webpack.js.org/guides/migrating/#automatic-loader-module-name-extension-removed
When executing:
serverless webpack invoke --function create --path mocks/create-event.json
I fixed this by going to webpack.config.js and changing from:
loaders: ['babel'],
To:
loaders: ['babel-loader'],
And now it works.

@RobbingDaHood Thanks for letting us know. I'll take a look into whats going on. Can you share your package.json? I'd like to see which version is giving this error.

@jayair Sorry, I should have thought of that.
After I experienced this, then I saw the "Serverless ES7 Service"-page: http://serverless-stack.com/chapters/serverless-es7-service.html
So I permanently deleted everything and started over. It was so early in the development I had not put anything on Git yet, so I cannot find it in version control either.
When I used Serverless ES7 Service I did not need to make the change the "babel"-part to "babel-loader".

@RobbingDaHood Hmm interesting. I'll see if I can replicate the issue.

Hi there,
I'm having similar issues as @martinsaporiti and @go4cas with babel. I have tried all the recommendations here to try to fix this error:
$ serverless webpack invoke --function create --path mocks/create-event.json
Serverless: WARNING: Plugin ServerlessWebpack uses deprecated hook before:deploy:createDeploymentArtifacts
Serverless: WARNING: Plugin ServerlessWebpack uses deprecated hook after:deploy:createDeploymentArtifacts
Serverless: Bundling with Webpack...
Time: 46ms
     Asset     Size  Chunks             Chunk Names
 create.js  3.27 kB       0  [emitted]  create
handler.js  1.93 kB       1  [emitted]  handler
Serverless: Run function create...

  Syntax Error -------------------------------------------

  Unexpected token import

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Stack Trace --------------------------------------------

SyntaxError: Unexpected token import
/Users/admin/projects/notes-app-api/.webpack/create.js:47
        import uuid from 'uuid';
        ^^^^^^
SyntaxError: Unexpected token import
    at Object.exports.runInThisContext (vm.js:78:16)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at ServerlessWebpack.loadHandler (/Users/admin/projects/notes-app-api/node_modules/serverless-webpack/lib/run.js:21:20)
    at ServerlessWebpack.run (/Users/admin/projects/notes-app-api/node_modules/serverless-webpack/lib/run.js:61:26)
    at ServerlessWebpack.tryCatcher (/Users/admin/projects/notes-app-api/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/admin/projects/notes-app-api/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/Users/admin/projects/notes-app-api/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/Users/admin/projects/notes-app-api/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/Users/admin/projects/notes-app-api/node_modules/bluebird/js/release/promise.js:693:18)
    at Promise._fulfill (/Users/admin/projects/notes-app-api/node_modules/bluebird/js/release/promise.js:638:18)
    at Promise._resolveCallback (/Users/admin/projects/notes-app-api/node_modules/bluebird/js/release/promise.js:432:57)
    at Promise._settlePromiseFromHandler (/Users/admin/projects/notes-app-api/node_modules/bluebird/js/release/promise.js:524:17)
    at Promise._settlePromise (/Users/admin/projects/notes-app-api/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/Users/admin/projects/notes-app-api/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/Users/admin/projects/notes-app-api/node_modules/bluebird/js/release/promise.js:693:18)
    at Promise._fulfill (/Users/admin/projects/notes-app-api/node_modules/bluebird/js/release/promise.js:638:18)
    at /Users/admin/projects/notes-app-api/node_modules/bluebird/js/release/nodeback.js:42:21
    at Compiler.<anonymous> (/Users/admin/projects/notes-app-api/node_modules/serverless-webpack/node_modules/webpack/lib/Compiler.js:194:14)
    at Compiler.emitRecords (/Users/admin/projects/notes-app-api/node_modules/serverless-webpack/node_modules/webpack/lib/Compiler.js:282:37)
    at Compiler.<anonymous> (/Users/admin/projects/notes-app-api/node_modules/serverless-webpack/node_modules/webpack/lib/Compiler.js:187:11)
    at /Users/admin/projects/notes-app-api/node_modules/serverless-webpack/node_modules/webpack/lib/Compiler.js:275:11
    at Compiler.applyPluginsAsync (/Users/admin/projects/notes-app-api/node_modules/tapable/lib/Tapable.js:60:69)
    at Compiler.afterEmit (/Users/admin/projects/notes-app-api/node_modules/serverless-webpack/node_modules/webpack/lib/Compiler.js:272:8)
    at Compiler.<anonymous> (/Users/admin/projects/notes-app-api/node_modules/serverless-webpack/node_modules/webpack/lib/Compiler.js:267:14)
    at /Users/admin/projects/notes-app-api/node_modules/async/lib/async.js:52:16
    at done (/Users/admin/projects/notes-app-api/node_modules/async/lib/async.js:246:17)
    at /Users/admin/projects/notes-app-api/node_modules/async/lib/async.js:44:16
    at /Users/admin/projects/notes-app-api/node_modules/graceful-fs/graceful-fs.js:43:10
    at /usr/local/lib/node_modules/serverless/node_modules/graceful-fs/graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:112:15)
From previous event:
    at PluginManager.invoke (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:217:22)
    at PluginManager.run (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:236:17)
    at variables.populateService.then (/usr/local/lib/node_modules/serverless/lib/Serverless.js:107:33)
    at runCallback (timers.js:651:20)
    at tryOnImmediate (timers.js:624:5)
    at processImmediate [as _immediateCallback] (timers.js:596:5)
From previous event:
    at Serverless.run (/usr/local/lib/node_modules/serverless/lib/Serverless.js:94:74)
    at serverless.init.then (/usr/local/lib/node_modules/serverless/bin/serverless:30: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:                     darwin
     Node Version:           7.4.0
     Serverless Version:     1.16.1

My .babelrc:
{
  "plugins": ["transform-runtime"],
  "presets": ["es2015", "stage-3"]
}

My webpack.config.js (I've also tried using loader: 'babel-loader' instead of the loaders array in the module rules:
var glob = require('glob');
var path = require('path');
var nodeExternals = require('webpack-node-externals');

// Required for Create React App Babel transform
process.env.NODE_ENV = 'production';

module.exports = {
    // Use all js files in project root (except
    // the webpack config) as an entry
    entry: globEntries('!(webpack.config).js'),
    target: 'node',
    // Since 'aws-sdk' is not compatible with webpack,
    // we exclude all node dependencies
    externals: [nodeExternals()],
    // Run babel on all .js files and skip those in node_modules
    module: {
        rules: [{
            test: /\.js$/,
            loaders: ['babel-loader'],
            include: __dirname,
            exclude: /node_modules/,
        }]
    },
    // We are going to create multiple APIs in this guide, and we are
    // going to create a js file to for each, we need this output block
    output: {
        libraryTarget: 'commonjs',
        path: path.join(__dirname, '.webpack'),
        filename: '[name].js'
    },
};

function globEntries(globPath) {
    var files = glob.sync(globPath);
    var entries = {};

    for (var i = 0; i < files.length; i++) {
        var entry = files[i];
        entries[path.basename(entry, path.extname(entry))] = './' + entry;
    }

    return entries;
}

My package.json:
{
  "name": "notes-app-api",
  "version": "1.0.0",
  "description": "",
  "main": "handler.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "aws-sdk": "^2.80.0",
    "babel-core": "^6.25.0",
    "babel-loader": "^7.1.1",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-stage-3": "^6.24.1",
    "glob": "^7.1.2",
    "serverless-webpack": "^1.0.0-rc.4",
    "webpack": "^3.1.0",
    "webpack-node-externals": "^1.6.0"
  },
  "dependencies": {
    "babel-runtime": "^6.23.0",
    "uuid": "^3.1.0"
  }
}

I have been following the steps from the beginning but took a break a few weeks ago before coming back to test my create.js file. Could something have changed in the upstream repositories since then?
Thanks in advance for any help

@d3sandoval That sounds like the serverless-webpack plugin did not do it's job. I'm just comparing your package.json to the one from this chapter and it seems like your serverless-webpack plugin is out of date. We did make some updates recently so that could be a reason why the one you have is old.
https://github.com/AnomalyInnovations/serverless-stack-demo-api/blob/add-a-create-note-api/package.json
Try updating it and let me know if that fixes it.

That seemed to work! But now I'm getting the 500 error:
$ serverless webpack invoke --function create --path mocks/create-event.json
Serverless: WARNING: Plugin ServerlessWebpack uses deprecated hook before:deploy:createDeploymentArtifacts
Serverless: WARNING: Plugin ServerlessWebpack uses deprecated hook after:deploy:createDeploymentArtifacts
Serverless: Bundling with Webpack...
Time: 328ms
     Asset     Size  Chunks             Chunk Names
 create.js  5.19 kB       0  [emitted]  create
handler.js  3.02 kB       1  [emitted]  handler
   [0] ./create.js 1.77 kB {0} [built]
   [1] external "uuid" 42 bytes {0} [not cacheable]
   [2] external "aws-sdk" 42 bytes {0} [not cacheable]
   [3] ./handler.js 463 bytes {1} [built]
Serverless: Run function create...
{ statusCode: 500,
  headers:
   { 'Access-Control-Allow-Origin': '*',
     'Access-Control-Allow-Credentials': true },
  body: '{"status":false}' }

Good call on updating to the latest. Not sure why npm update wouldn't have caught that.

@d3sandoval Try debugging it using these steps - http://serverless-stack.com/chapters/add-a-create-note-api.html#common-issues

@jayair good call :) Typing is hard! Turns out nodeId =/= noteId. I'm getting the 200 response now!

hi! When i run the following command in the root:

serverless webpack invoke --function create --path mocks/create-event.json

I'm getting this:
  ### Serverless Error ---------------------------------------

  Serverless command "webpack" not found

  Run "serverless help" for a list of all available commands.

  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:                     darwin
     Node Version:           8.0.0
     Serverless Version:     1.17.0

I've installed all dependencies as shown. I also tried manually installing webpack with NPM in the root. What do you think went wrong here?
Thanks

I just have a question about CORS. Why do the headers "Access-Control-Allow-Origin" and the others need to be defined in both the YML and the Success method? Shouldn't setting CORs to true in the YML take care of the pre-flight?

@peterschwarz21 That's a good question. By setting the cors: true we are telling API Gateway to respond to the OPTIONS preflight request for our API. And in the tutorial we want to control the headers that we are sending in our Lambda (we are using lambda-proxy integration). So we need to specify the Access-Control- headers ourselves. Here is some info on this - https://serverless.com/framework/docs/providers/aws/events/apigateway/#enabling-cors

Thanks for the quick reply! I think I got it now. You da best!

Getting an error saying the module build 'failed', 'Couldn't find preset es-2015" relative to directory. My package.json seems to be fully up to date, here it is below:

Nevermind, fixed it: In the babelrc file, I had to change the preset name from just 'es-2015' as the tutorial stated, to the full npm name 'babel-preset-2015'.

@mikhaelbendavid That's really weird. The .babelrc is supposed to use es2015 as the preset. https://babeljs.io/docs/plugins/preset-es2015/#usage-via-babelrc-recommended-
Can I see your full .babelrc?

I believe there is a typo in the following sentence on from this page: "We are going to expand more on where this id in the coming chapters when we set up our Cognito Identity Pool."

@bharloe Thank you!

Jayair - here is my .babelrc - I'm still getting a 500 error code, so need to troubleshoot to get the 200 before I move on.

@mikhaelbendavid Hmm just read your previous comment again. The preset is es2015 not es-2015. Not sure if that is the issue.

Modified the preset to just be 'es2015', not full babel-preset-2015. Webpack is still working, but still getting 500 error - haven't refactored the code yet, no sense in moving on until then.
Here's the repo I'm using to track progress:
https://github.com/mikhaelbendavid/serverlessblog

@mikhaelbendavid I ran your code and recorded the error message in create.js and this is the error:
"ResourceNotFoundException: Requested resource not found"
This is a dynamodb error. Are you positive you've already set up your dynamo db database in AWS and its items match exactly what you have in the params variable? The items are case sensitive so keep that in mind.

@mikhaelbendavid I ran your code and it works for me. If you edit your error response to look like this it will record the error for you:
//Return status code 500 on error
	if (error) {
		const response = {
			statusCode: 500,
			headers: headers,
			body: JSON.stringify({status:false}),
			error: error
		};
		callback(null, response);
		return;

I'm guessing you're getting a 500 because it is not connecting to the dynamo db database. If that's the case there's 2 things to check. Make sure you have configured your code to be in the same region as your dynamo db database at the top of create.js. If that is set, then make sure you have the dynamodb database itself configured properly and that all the items match exactly what you have in the code. Keep in mind it is case sensitive, so if you have 'userId' in the params object, but in your database it is 'userid', you will get a 500 error.

@bharloe - You are exactly correct! The names of the userId and noteId were 'userid' and 'notesid' - sloppiness on my part. I just got a 200 code!

@bharloe Great work! Thanks for helping out!

My pleasure

@oliv9286

If you're not using your default profile then in your create.js you need to do
const credentials = new AWS.SharedIniFileCredentials({profile: 'profile_name'}); AWS.config.credentials = credentials;

I ran into the same issue and used  AWS.SharedIniFileCredentials as well.
Be aware that this works when testing the API locally, but will result in a 500 response with a credential error in the logs when you deploy that code to Lambda because your local credential file is not going to be available on Lambda.
I have not found a workaround for using the non-default profile of a multiple profile configuration that will work for both local and deployed code (other than manually modifying my ~/.aws/credentails file to use a single profile, or commenting out the above code before deployment).
Note: I do have my profile attribute set in the provider block of the serverless.yml file. This solves the profile issue for deploying code, but has no effect when testing locally.

Silly mistake on my part: I was getting the ResourceNotFoundException: Requested resource not found error. Something no one mentioned in this thread was to check that TableName in the create.js params was the same as your dynamoDB table.

Suggestion: Make it explicit that create.js should be placed in the root directory.

@etsung Good point, I'll add a note.

What are the other authorisations available for lambda functions other than Cognito pool and IAM?

@jcowley I was having a resource not found 500 response because I was not on the North Virginian region. I would take a look at your dynamoDB table and your user pools to make sure that they are hosted in the same region.

@VSingh98: Thanks, but I think mine was a different issue. As I mentioned above, the 500 error I was seeing was due to trying to use AWS.SharedIniFileCredentials, which won't work when running code on Lambda. Different issue.

@oliv9286 and anyone else trying to use an AWS profile other than default when testing locally with serverless webpack invoke.
Found the solution here!!. You add the following to your serverless.yml file (this is in addition to adding profile: your-profile-name, which only helps for deployment):
provider:
  environment:
    AWS_PROFILE: your-profile-name

This ensures that the AWS_PROFILE environment variable is picked when invoking locally.
This was driving me nuts! I'm using this for a personal project and my local testing kept running against my production AWS account! Not good.

@yashg5 You can add a custom authorizer (your own login system) or social logins but they are tied into IAM.

@jcowley Good find. I ran into that as well recently. We'll add a note to the tutorial about it.

I'm not sure if it is me. I did initially get status 500 but after 16 hours or so I now got status 200 and I'm able to see an item in dynamodb. It is really weird.

@hmartus That's really strange. Is this on a completely new AWS account?

I get the 500 when invoking locally, maybe I should have moved this issue here:
https://github.com/AnomalyInnovations/serverless-stack-demo-api/issues/5

Still stuck on the SyntaxError: Unexpected token import error... Not sure what it could be, I've updated everything. It honestly doesn't even look like serverless ran at all, it just spits out this error:
`(function (exports, require, module, __filename, __dirname) { import uuid from "uuid";
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at AwsInvokeLocal.invokeLocalNodeJs (C:\Users\kalab\AppData\Roaming\npm\node_modules\serverless\lib\plugins\aws\invo
keLocal\index.js:251:33)
at AwsInvokeLocal.invokeLocal (C:\Users\kalab\AppData\Roaming\npm\node_modules\serverless\lib\plugins\aws\invokeLoca
l\index.js:125:19)
at AwsInvokeLocal.tryCatcher (C:\Users\kalab\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\re
lease\util.js:16:23)
at Promise._settlePromiseFromHandler (C:\Users\kalab\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebi
rd\js\release\promise.js:512:31)
at Promise._settlePromise (C:\Users\kalab\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\relea
se\promise.js:569:18)
at Promise._settlePromise0 (C:\Users\kalab\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\rele
ase\promise.js:614:10)
at Promise._settlePromises (C:\Users\kalab\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\rele
ase\promise.js:693:18)
at Async._drainQueue (C:\Users\kalab\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\as
ync.js:133:16)
at Async._drainQueues (C:\Users\kalab\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\a
sync.js:143:10)
at Immediate.Async.drainQueues (C:\Users\kalab\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js
release\async.js:17:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)`
.babelrc file:
{ 	"plugins": ["transform-runtime"], 	"presets": ["es2015", "react-app"] }
package.json file:
{   "name": "notes-app-api",   "version": "1.0.0",   "description": "",   "main": "handler.js",   "scripts": {     "test": "echo \"Error: no test specified\" && exit 1"   },   "keywords": [],   "author": "",   "license": "ISC",   "devDependencies": {     "aws-sdk": "^2.131.0",     "babel-core": "^6.26.0",     "babel-loader": "^7.1.2",     "babel-plugin-transform-runtime": "^6.23.0",     "babel-preset-es2015": "^6.24.1",     "babel-preset-stage-3": "^6.24.1",     "serverless-webpack": "^3.1.2",     "webpack": "^3.8.1",     "webpack-node-externals": "^1.6.0"   },   "dependencies": {     "babel-cli": "^6.26.0",     "babel-preset-node6": "^11.0.0",     "babel-runtime": "^6.26.0",     "uuid": "^3.1.0"   } }
Any ideas? Thanks!

First off, thanks so much for the amazing tutorial. SOOO helpful. Really a great intro to this set of technologies. I used to teach web dev online, and I am really impressed by how well you guys have put this together.

I'm running into a weird/problematic error in an app that uses an API modeled directly off of this one. This is the first chapter suggesting the pattern that is breaking in my app, so I figured I'd bring the bug up here and see if you guys have any thoughts.
The bug (laid out in significantly more detail in this Stack Overflow post) is that the Cognito Identity ID associated with a pair of login creds I and some fellow developers are using changes! So two devs on two different local servers can log in as the same user, and the event.requestContext.identity.cognitoIdentityId value that hits the lambda is different between them.
This means that we can't look up records by that ID. Is this expected behavior?! Do you have a suggestion for getting around it? I don't see username or anything else reliably unique/consistent coming in as part of the event context!
Thanks!

@sashafklein This should not really happen. One way to check what is going on is to look up the users you have in your User Pool and the Identity Pool. And use the login credentials to see which User Pool user is being picked up. At the same time use the event.requestContext.identity.cognitoIdentityId to look up Identity Pool user that it is picking up.
Also, I'd be curious to hear what https://stackoverflow.com/users/3330296/rachit-dhall has to say about your issue on Stack Overflow.

Thanks @jayair! I'll be sure to update you if/when I hear back. It is weird. There are only 4 users in my user pool, and the creds connecting each local developer to the right user/identity pools are identical, because the file with the creds is checked into source control. That's also how I'm accessing the cognitoIdentityId, so it looks like I'm not grabbing the wrong attribute. May have something to do with different devs in different countries? I'll update this thread.

I am one of the people getting a 500. I have debugged the issue and found that if I change the parameter noteId to noteID the issue goes away. Since the source for the "noteId" version is the canonical stuff in https://serverless-stack.com/chapters/add-a-create-note-api.html, this is a mite confusing. Any ideas would be welcome.

Found it - the field was mistyped in DynamoDB as noteID rather than noteID.

@lucasgonze Ah yeah, that is an annoying issue.

For anyone experiencing a persistent 500 error, the issue may be with how you are using your promise library. In the code in this chapter, the promise method is invoked on DynamoDB as we are returning the action, like so:
export function call(action, params){   const dynamoDB = new AWS.DynamoDB.DocumentClient();   return dynamoDB[action].promise(); }
In my environment, this throws a 500. If, on the other hand, I do not invoke the promise method it returns a 200:
export function call(action, params){     const dynamoDB = new AWS.DynamoDB.DocumentClient();     return dynamoDB[action].promise; }
I hope this helps!

@leonardreidy That's interesting. I'm not sure what is different in your environment but the docs have it as promise() - http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Request.html#promise-property

Hi,
I used this guide before to create the note app and it all worked pretty easily. Now I am trying to use this guide to make a different app, the main difference is the DynamoBD table has a lot more items than the notes one had. But no matter how much I try I cannot get it to work it keeps coming up with this issue. (I am on the "Add a Create Note API" part):
Serverless: Bundling with Webpack...
Time: 967ms
Asset     Size  Chunks             Chunk Names
create.js  5.53 kB       0  [emitted]  create
[0] ./create.js 2.69 kB {0} [built]
[1] external "babel-runtime/core-js/json/stringify" 42 bytes {0} [not cacheable]
[2] external "uuid" 42 bytes {0} [not cacheable]
[3] external "aws-sdk" 42 bytes {0} [not cacheable]
{
"statusCode": 500,
"headers": {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": true
},
"body": "{"status":false}"
}
I am using the same AWS account details and IAM user, but I created new ones of all the other elements, like the table, bucket, cognito user pool and test user
My package.json is as follows:
{
"name": "target-conferences-api",
"version": "1.0.0",
"description": "",
"main": "handler.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"aws-sdk": "^2.141.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-3": "^6.24.1",
"serverless-webpack": "^3.1.2",
"webpack": "^3.8.1",
"webpack-node-externals": "^1.6.0"
},
"dependencies": {
"babel-runtime": "^6.26.0",
"uuid": "^3.1.0"
}
}
I have tried a lot of things I have seen on this feed already but cannot seem to solve the issue.
Hopefully I can get some help here.
Thanks!

@Kalaborative I'm assuming you are doing a local invoke when getting the error:
$ AWS_PROFILE=aws_profile_name sls invoke local --function create --path mocks/create-event.json
I get the same error for the above but...
$ AWS_PROFILE=aws_profile_name sls webpack invoke --function create --path mocks/create-event.json
This works fine for me when not invoking locally. I was hoping that the issue was the AWS_PROFILE not being used but I've ruled that out. I'm puzzling this out still because it bothers me but since it works when run remotely, I'm moving on for now.

@roxy-target If you try to debug the error using these instructions (https://serverless-stack.com/chapters/add-a-create-note-api.html#common-issues) what do you see?

@mcgarrah So sls web pack invoke works for you but sls invoke local does not?

@jayair Yes but I've since found an issue with my iam permissions that might be part of the issue. I'll retest and report back. I'm building all the resources from the serverless.yml file including the policies and roles.

I am getting this error please help:
`Toyeeb notes-app-api $ serverless invoke local --function create --path mocks/create-event.json
Serverless: Bundling with Webpack...
Time: 1387ms
Asset     Size  Chunks             Chunk Names
create.js  4.97 kB       0  [emitted]  create
[0] ./create.js 2.13 kB {0} [built]
[1] external "babel-runtime/core-js/json/stringify" 42 bytes {0} [not cacheable]
[2] external "uuid" 42 bytes {0} [not cacheable]
[3] external "aws-sdk" 42 bytes {0} [not cacheable]
Syntax Error -------------------------------------------
in JSON at position 33
 For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

My initial local invoke generated a 500 error. I have since fixed with key/column name confusion with my DynamoDB table. I made the columns UserId and NoteId and the create.js was doing something different.
So now my local invoke generates a 200 error, but I still get the webpack errors.
[11:18:23]dcharling@us-c02tf23vg8wn:~/Personal/dev/scratch> serverless invoke local --function create --path mocks/create-event.json
Serverless: Bundling with Webpack...
 These are just debug messages the serverless-webpack plugin is generating. As long as the response is 200 we should be good.

How do I get user's attributes from event.requestContext.identity.cognitoIdentityId?

@fcostarodrigo This is a bit trickier but here is roughly how to do it:
event.requestContext.identity.cognitoAuthenticationProvider gives you a string that looks like this cognito-idp.us-east-1.amazonaws.com/us-east-1_Jw5lUuxG2,cognito-idp.us-east-1.amazonaws.com/us-east-1_Jw5lUuabc:CognitoSignIn:5f24cbc9-aaaa-bbbb-cccc-eafaeced45ff
Where us-east-1_Jw5lUuabc is the User Pool Id and 5f24cbc9-aaaa-bbbb-cccc-eafaeced45ff is the User Pool User Id. You can use these two to get the user:
import AWS from 'aws-sdk';

this.client = new AWS.CognitoIdentityServiceProvider();
const user = this.client.adminGetUser({
  UserPoolId: userPoolId,
  Username: userPoolUserId,
}).promise();

And with the user object you can use user.UserAttributes to get the attributes you need.

I keep getting this no matter what I do, any help would be greatly appreciated...
Johnny-B:notes-app-api johnblakley$ serverless invoke local --function create --path mocks/create-event.json
Serverless: Bundling with Webpack...
Time: 716ms
Asset     Size  Chunks             Chunk Names
create.js  5.02 kB       0  [emitted]  create
[0] ./create.js 2.18 kB {0} [built]
[1] external "babel-runtime/core-js/json/stringify" 42 bytes {0} [not cacheable]
[2] external "uuid" 42 bytes {0} [not cacheable]
[3] external "aws-sdk" 42 bytes {0} [not cacheable]
{
"statusCode": 500,
"headers": {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": true
},
"body": "{"status":false}",
"error": {
"message": "Missing credentials in config",
"code": "CredentialsError",
"time": "2017-12-02T13:58:44.259Z",
"retryable": true,
"originalError": {
"message": "Could not load credentials from any providers",
"code": "CredentialsError",
"time": "2017-12-02T13:58:44.259Z",
"retryable": true,
"originalError": {
"message": "Connection timed out after 1000ms",
"code": "TimeoutError",
"time": "2017-12-02T13:58:44.258Z",
"retryable": true
}
}
}
}
Johnny-B:notes-app-api johnblakley$ AWS_PROFILE=aws_profile_name sls webpack invoke --function create --path mocks/create-event.json
Serverless Error ---------------------------------------
Serverless command "webpack invoke" not found
Run "serverless help" for a list of all available commands.
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:                     darwin
Node Version:           8.9.1
Serverless Version:     1.24.1

@inventanew It seems like an issue with your credentials. Can you make sure you've configured your CLI - https://serverless-stack.com/chapters/configure-the-aws-cli.html?
And check your ~/.aws/credentials to see if the info is in there.

thanks Jayair, I cannot believe I could miss something so simple, I switched the key secret from the key itself, man I feel dumb

@inventanew No worries. Thanks for reporting back.

Does anyone have any insight in regards to getting past this error?

When calling create after refactoring, this code block causes an issue
    await dynamoDbLib.call("put", params);
    callback(null, success(params.Item));
  }```

'Await is a reserved word'. Assuming this is because the dynamo-dblib doesn't have async on the function?

@nicksmithr Hmm we set this up in this chapter - https://serverless-stack.com/chapters/add-support-for-es6-es7-javascript.html
Can you double check if you completed that step?

@nicksmithr Did you put the keyword async in the beginning of the function? You are only allowed to use await in async functions.

@jayair @fcostarodrigo Ah yes, I didn't have ES7 configured. Thanks both!

In the top section ("Add the Function"), I wonder if the two appearances of JSON.stringify are superfluous?  When I run the code exactly as written in the tutorial, I get extra escapes:
{     "statusCode": 200,     "headers": {         "Access-Control-Allow-Origin": "*",         "Access-Control-Allow-Credentials": true     },     "body": "{\"userId\":\"USER_SUB-1234\",\"noteId\":\"15e55280-df69-11e7-b24c-29b4f0f7fc22\",\"content\":\"hello world\",\"attachment\":\"hello.jpg\",\"createdAt\":1513102809000}" }
Which looks like it's a JSON of a JSON.  If I take out the JSON.stringify
    const response = {       statusCode: 200,       headers: headers,       body: params.Item     };
then it emits what the tutorial says it should.
I notice that another of the comments above also shows the extra backslash escapes.  Of course this becomes moot in the next step later on the page, but still curious why it might be.

@SpencerGreene What is returned on AWS is the body portion as a JSON string. That is why it is encoded and why it appears double encoded on local.
It looks a bit confusing on local because it is mocking the response you would normally get on AWS.

Anyone know what is going on here? I just got done working out a 500 error and now this is popping up,

@jdbohrman It seems like a path issue or the dynamodb-lib.js was not added in properly. Can you confirm there is a libs/ directory off root of your project?

I don't understand why you need to enable CORS both in the config file and in the code headers. Why won't once be enough?

Cannot read property 'events' of null
I'm getting the above error when attempting to run serverless invoke local --function create --path mocks/create-event.json
`import uuid from "uuid";
import AWS from "aws-sdk";
AWS.config.update({ region: "ap-southeast-2" });
const dynamoDb = new AWS.DynamoDB.DocumentClient();
export function main(event, context, callback) {
// request body is passed in as a JSON encoded string using 'event.body'
const data = JSON.parse(event.body);
const params = {
    TableName: "notes",
     // 'Item' contains the attributes of the item to be created
     // - 'userId': user identities are federated through the
     // Cognito Identity Pool, we will use the identity id
     // as the user id of the authenticated user
     // - 'noteId': a unique uuid
     // - 'content': parsed from request body
     // - 'attachment': parsed from request body
     // - 'createdAt': current Unix timestamp
     Item: {
         userId: event.requestContext.identity.cognitoIdentityId,
         notesId: uuid.v1(),
         content: data.content,
         attachment: data.attachment,
         createdAt: new Date().getTime()
     }
};

dynamoDb.put(params,(error,data) => {
    // Set response headers to enable Cross Origin Resource Sharing
    const headers = {
        "Access-Control-Allow-Origin": "**",
        "Access-Control-Allow-Credentials": true
    };

    // return status code 500 on error
    if (error) {
        const response = {
            statusCode: 500,
            headers: headers,
            body: JSON.stringify({status:false})
        };
        callback(null,response);
        return;
    }
// return status code 200 and the newly created item
const response = {
    statusCode: 200,
    headers: headers,
    body: JSON.stringify(params.Item)
};
callback(null,response);

});

}`
{     "body": "{\"content\":\"hello world\",\"attachment\":\"hello.jpg\"}",     "requestContext": {         "identity": {             "cognitoIdentityId": "USER-SUB-1234"         }     } }

@Vadorequest The one in the config is to enable it CORS. But what you decide to send in the headers is in the code.

@ReedME Hmm that looks okay. Which version of Serverless are you using?

@jayair Serverless version 1.26.0

@ReedME Can I try out your repo to test this?

@jayair https://github.com/ReedME/scratchnotes

@ReedME Your serverless.yml is not properly formatted. Make sure it looks like this - https://github.com/AnomalyInnovations/serverless-stack-demo-api/blob/add-a-create-note-api/serverless.yml

Thank you so much for creating this tutorial! As a student, this provides me with a great introduction to creating Web Apps. I ran into the following error, and have been stumped for a while when I try to run serverless invoke local --function create --path mocks/create-event.json:
Serverless: Bundling with Webpack...
Time: 359ms
    Asset  Size  Chunks             Chunk Names
create.js  5 kB       0  [emitted]  create
   [0] ./create.js 2.16 kB {0} [built]
   [1] external "babel-runtime/core-js/json/stringify" 42 bytes {0} [not cacheable]
   [2] external "uuid" 42 bytes {0} [not cacheable]
   [3] external "aws-sdk" 42 bytes {0} [not cacheable]
{
    "statusCode": 500,
    "headers": {
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Allow-Credentials": true
    },
    "body": "{\"status\":false}"
}

I have imported uuid and aws-sdk in create.js, as well as have them inside my package.json devDependencies. Thank you so much for the help!

Here is my error. I've set up the aws configuration. The body is actually posting to the db. Not sure why the authentication error.
I manually added a directory .aws/config and .aws/credentials as they never showed up after the initial aws configure command. Any help much appreciated.
`Serverless: Bundling with Webpack...
Time: 343ms
Built at: 2018-2-26 17:38:39
Asset      Size  Chunks             Chunk Names
create.js  1.51 KiB       0  [emitted]  create
Entrypoint create = create.js
[0] external "aws-sdk" 42 bytes {0} [built]
[1] external "uuid" 42 bytes {0} [built]
[2] external "babel-runtime/core-js/json/stringify" 42 bytes {0} [built]
[3] ./create.js 2.05 KiB {0} [built]
WARNING in configuration
The 'mode' option has not been set. Set 'mode' option to 'development' or 'production' to enable defaults for this environment.
params:  { TableName: 'notes',
Item:
{ userId: 'USER-SUB-1234',
noteId: '8e1ea2f0-1b56-11e8-a9f2-11680d2c2ad9',
content: 'hello world',
attachment: 'hello.jpg',
createdAt:<PHONE_NUMBER>031 } }
error:  { Error: connect EHOSTUNREACH <IP_ADDRESS>:80
at Object.exports._errnoException (util.js:1024:11)
at exports._exceptionWithHostPort (util.js:1047:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1150:14)
message: 'Missing credentials in config',
code: 'CredentialsError',
errno: 'EHOSTUNREACH',
syscall: 'connect',
address: '<IP_ADDRESS>',
port: 80,
time: 2018-02-27T00:38:43.112Z,
originalError:
{ message: 'Could not load credentials from any providers',
code: 'CredentialsError',
errno: 'EHOSTUNREACH',
syscall: 'connect',
address: '<IP_ADDRESS>',
port: 80,
time: 2018-02-27T00:38:43.112Z,
originalError:
{ code: 'EHOSTUNREACH',
errno: 'EHOSTUNREACH',
syscall: 'connect',
address: '<IP_ADDRESS>',
port: 80,
message: 'connect EHOSTUNREACH <IP_ADDRESS>:80' } } }
{
"statusCode": 500,
"headers": {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": true
},
"body": "{"status":false}"
}
`

Hi, Please, someone, help me. I don't like to stuck with this error
{ NetworkingError: Invalid character in header content ["Authorization"]
at validateHeader (_http_outgoing.js:506:11)
at ClientRequest.setHeader (_http_outgoing.js:510:3)
at new ClientRequest (_http_client.js:173:14)
at Object.request (https.js:241:10)
at Object.request (C:\Users\Sina\AppData\Roaming\npm\node_modules\serverless\node_modules\agent-base\patch-core.js:52:20)
at features.constructor.handleRequest (E:\node\notes-app\node_modules\aws-sdk\lib\http\node.js:42:23)
at executeSend (E:\node\notes-app\node_modules\aws-sdk\lib\event_listeners.js:304:29)
at Request.SEND (E:\node\notes-app\node_modules\aws-sdk\lib\event_listeners.js:318:9)
at Request.callListeners (E:\node\notes-app\node_modules\aws-sdk\lib\sequential_executor.js:101:18)
at Request.emit (E:\node\notes-app\node_modules\aws-sdk\lib\sequential_executor.js:77:10)
at Request.emit (E:\node\notes-app\node_modules\aws-sdk\lib\request.js:683:14)
at Request.transition (E:\node\notes-app\node_modules\aws-sdk\lib\request.js:22:10)
at AcceptorStateMachine.runTo (E:\node\notes-app\node_modules\aws-sdk\lib\state_machine.js:14:12)
at E:\node\notes-app\node_modules\aws-sdk\lib\state_machine.js:26:10
at Request. (E:\node\notes-app\node_modules\aws-sdk\lib\request.js:38:9)
at Request. (E:\node\notes-app\node_modules\aws-sdk\lib\request.js:685:12)
at Request.callListeners (E:\node\notes-app\node_modules\aws-sdk\lib\sequential_executor.js:115:18)
at callNextListener (E:\node\notes-app\node_modules\aws-sdk\lib\sequential_executor.js:95:12)
at E:\node\notes-app\node_modules\aws-sdk\lib\event_listeners.js:220:9
at finish (E:\node\notes-app\node_modules\aws-sdk\lib\config.js:320:7)
at E:\node\notes-app\node_modules\aws-sdk\lib\config.js:338:9
at SharedIniFileCredentials.get (E:\node\notes-app\node_modules\aws-sdk\lib\credentials.js:126:7)
at getAsyncCredentials (E:\node\notes-app\node_modules\aws-sdk\lib\config.js:332:24)
at Config.getCredentials (E:\node\notes-app\node_modules\aws-sdk\lib\config.js:352:9)
at Request.SIGN (E:\node\notes-app\node_modules\aws-sdk\lib\event_listeners.js:192:22)
at Request.callListeners (E:\node\notes-app\node_modules\aws-sdk\lib\sequential_executor.js:101:18)
at Request.emit (E:\node\notes-app\node_modules\aws-sdk\lib\sequential_executor.js:77:10)
at Request.emit (E:\node\notes-app\node_modules\aws-sdk\lib\request.js:683:14)
at Request.transition (E:\node\notes-app\node_modules\aws-sdk\lib\request.js:22:10)
at AcceptorStateMachine.runTo (E:\node\notes-app\node_modules\aws-sdk\lib\state_machine.js:14:12)
at E:\node\notes-app\node_modules\aws-sdk\lib\state_machine.js:26:10
at Request. (E:\node\notes-app\node_modules\aws-sdk\lib\request.js:38:9)
at Request. (E:\node\notes-app\node_modules\aws-sdk\lib\request.js:685:12)
at Request.callListeners (E:\node\notes-app\node_modules\aws-sdk\lib\sequential_executor.js:115:18)
at Timeout.callNextListener [as _onTimeout] (E:\node\notes-app\node_modules\aws-sdk\lib\sequential_executor.js:95:12)
at ontimeout (timers.js:478:11)
at tryOnTimeout (timers.js:302:5)
at Timer.listOnTimeout (timers.js:262:5)
message: 'Invalid character in header content ["Authorization"]',
code: 'NetworkingError',
region: 'eu-west-1',
hostname: 'dynamodb.eu-west-1.amazonaws.com',
retryable: true,
time: 2018-02-28T17:36:49.058Z }
{
"statusCode": 500,
"header": {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": true
},
"body": "{"status":false}"
}

Just a quick question.
Can I add a identifier in my event.requestContext.identity json like,
event.requestContext.identity.orgId
For e.g event.requestContext.identity.orgId should return me say 'ORG001'
I'll be using orgId inside my application to use it as a primary partition key for my multi-tenant application. The noteId will be my sort key and pehaps I'll be adding Index for 'userId'.
Thanks,
Bharat Chand

@Dorostkar What command are you running that shows this error?

@19bharatvikram I don't think you can use it directly. You can store the mapping on your end. Or you can use something like https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-sync.html

@jayair
Found a way to set orgid(companyId) as custom attribute for cognito user and then using existing Cognito User Pool as the authorizer:
get:
Defines an HTTP API endpoint that calls the main function in get.js
- path: url path is /notes/{id}
- method: GET request
handler: get.main
events:
  - http:
      path: case/{id}
      method: GET
      integration: lambda
      authorizer:
        arn: arn:aws:cognito-idp:ap-south-1:xxxx:userpool/ap-south-1_xxxxxxxx
        claims:
          - email
          - family_name
          - custom:orgid

https://serverless.com/framework/docs/providers/aws/events/apigateway/
https://maketips.net/tip/175/include-custom-attributes-in-cognito-claims
So that I can get orgid in requestContext like below
event.requestContext.authorizer.claims.family_name
or,
event.requestContext.authorizer.claims['custom:orgid']
But now not able to call lambda through API Gateway. As for API gateway the Auth: AWS_IAM has changed to Auth: 1_hfxxr2Gx due to with API authorization fails.
please suggest if there will be code change for making API call.
Thanks,

@jayair, fortunately, I have solved the issue. The problem was bcz of the AWS credential that I configured in the serverless framework and it was for different IAM.

@19bharatvikram Yeah so with this approach the authorizer is directly Cognito User Pool. We have an older version of the tutorial that used this approach. To call the API you can refer to this - https://59caadbd424ef20abdc342b4--serverless-stack.netlify.com/chapters/call-the-create-api.html

When I enter the command for the test into the CLI, nothing happens. It hesitates for a second and then gives me another command prompt. I'm not even sure what else to tell you...my test user is verified, my user pool seems to be configured correctly, all the code is identical to the tutorial. I don't have multiple profiles. Help!

@sarahbattey Which command is this?

getting error 'Function "create" doesn't exist in this Service'
serverless invoke local --function create --path mocks/createevent.json
Serverless Error ---------------------------------------
Function "create" doesn't exist in this Service
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:           9.4.0
Serverless Version:     1.26.0

@jayair $ serverless invoke local --function create --path mocks/create-event.json

@sarahbattey Which version of Serverless are you using?
@nelsoftcom This seems like an issue with your serverless.yml. Make sure it is indented exactly like the one in the tutorial - https://github.com/AnomalyInnovations/serverless-stack-demo-api/blob/add-a-create-note-api/serverless.yml

@jayair I have copied the serverless.yml from the link and changed to us-east-2.
I'm still getting the same above error.
thank you :)

@nelsoftcom Can I see your serverless.yml? And I'm assuming you have a file createevent.json as opposed to create-event.json.

@jayair Yes I was wrong with the file name - i have changed that to create-event.json.
using this command now.
serverless invoke local --function create --path mocks/create-event.json
Please see my file. thanks
service: mynotes-app-api
Use serverless-webpack plugin to transpile ES6/ES7
plugins:

serverless-webpack

Enable auto-packing of external modules
custom:
webpackIncludeModules: true
provider:
name: aws
runtime: nodejs6.10
stage: prod
region: us-east-2
'iamRoleStatement' defines the permission policy for the Lambdafunction.
In this case Lambda functions are granted with permissions to access DynamoDB.
iamRoleStatements:

Effect: Allow
Action:
dynamodb:DescribeTable
dynamodb:Query
dynamodb:Scan
dynamodb:GetItem
dynamodb:PutItem
dynamodb:UpdateItem
dynamodb:DeleteItem
Resource: "arn:aws:dynamodb:us-east-2::"
functions:

Defines an HTTP API endpoint that calls the main function in create.js
- path: url path is /notes
- method: POST request
- cors: enabled CORS (Cross-Origin Resource Sharing) for browser cross
domain api call
- authorizer: authenticate using the AWS IAM role
create:
handler: create.main
events:

http:
path: mynotes
method: post
cors: true
authorizer: aws_iam

@nelsoftcom I'm not sure if you didn't paste it properly but it needs to be indented exactly like this https://github.com/AnomalyInnovations/serverless-stack-demo-api/blob/master/serverless.yml

@jayair I'm running 1.26.1

@jayair Thank you. Passed that level - yes indent was the issue. Now I', getting status code 500
serverless invoke local --function create --path mocks/create-event.json
Serverless: Bundling with Webpack...
Time: 1307ms
Asset     Size  Chunks             Chunk Names
create.js  6.75 kB       0  [emitted]  create
[0] ./create.js 2.38 kB {0} [built]
[1] external "babel-runtime/regenerator" 42 bytes {0} [not cacheable]
[2] external "babel-runtime/helpers/asyncToGenerator" 42 bytes {0} [not cacheable]
[3] external "uuid" 42 bytes {0} [not cacheable]
[4] ./libs/dynamodb-lib.js 483 bytes {0} [built]
[5] external "aws-sdk" 42 bytes {0} [not cacheable]
[6] ./libs/response-lib.js 719 bytes {0} [built]
[7] external "babel-runtime/core-js/json/stringify" 42 bytes {0} [not cacheable]
{
"statusCode": 500,
"headers": {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": true
},
"body": "{"status":false}"
}

@nelsoftcom This is pretty common and we have a little note at the bottom of the chapter for it  - https://serverless-stack.com/chapters/add-a-create-note-api.html#common-issues
@sarahbattey That looks okay. I'm not entirely sure what the issue is. Can you share your directory structure and show me where you are running your command from?

@jayair thank you :) create-event and get-event works. thanks for the help.

@jayair here's a screenshot of my file structure and my serverless.yml too, just in case. I can't thank you enough for your help!

@sarahbattey Yeah the structure is a bit weird. Compare it to the one we have in the tutorial - https://github.com/AnomalyInnovations/serverless-stack-demo-api.
And you run your serverless commands at the level where your serverless.yml is.

@jayair Wow...I have NO idea what happened there. I'm going to restart. This will be my third start (the first try was due to Route 53 and not you)...I'm doing this to get more familiar with AWS and React so every error and every weird thing is a learning experience! Thanks again for everything you've done!

Can you comment on why the functions are async? I would think the simpler approach would be to make calls synchronous unless there is a need for async calls. I'm asking because I wanted to try and reuse some of the basic CRUD functions but am having problems with the async sub functions.

I'm running $ serverless invoke local --function create --path mocks/create-event.json
My return is:
{
"statusCode": 500,
"headers": {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": true
},
"body": "{"status":false}"
}
It appears to be a permissions/IAM issue:
AccessDeniedException: User: arn:aws:iam::123186399999:user/ is not authorized to perform: dynamodb:PutItem on resource: arn:aws:dynamodb:us-east-1:123186399999:table/notes
I don't want to go in and just start changing permissions.  I feel like I'm missing some fundamental lesson or item that I should know before moving on.
Any help would be very much appreciated.

Based on @oliv9286 's comment, I used the following to set non-default credentials.
diff --git a/libs/dynamodb-lib.js b/libs/dynamodb-lib.js
index f08b4d8..de2b4f0 100644
--- a/libs/dynamodb-lib.js
+++ b/libs/dynamodb-lib.js
@@ -1,6 +1,7 @@
 import AWS from "aws-sdk";

-AWS.config.update({ region: "us-east-1" });
+const credentials = new AWS.SharedIniFileCredentials({profile: 'personal'});
+AWS.config.update({ region: "us-east-1", credentials: credentials });

 export function call(action, params) {
   const dynamoDb = new AWS.DynamoDB.DocumentClient();

@ahammond So this would work when invoking locally but when you deploy the Lambda function won't be able to find the personal credentials (AFAIK). We cover this in the tutorial, you can use this command to invoke locally with non-default credentials.
$ AWS_PROFILE=myProfile serverless invoke local --function create --path mocks/create-event.json

Did that not work for you?

Thank you @jayair

@F-Adam-B Is the issue resolved for you?

I was facing the same issue mentioned by @F-Adam-B , saying

error:  { Error: connect EHOSTUNREACH <IP_ADDRESS>:80
at Object.exports._errnoException (util.js:1024:11)
at exports._exceptionWithHostPort (util.js:1047:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1150:14)
message: 'Missing credentials in config',

That got resolved by exporting AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. Now I'm getting following error:

{ ResourceNotFoundException: Requested resource not found
at Request.extractError (/Users/absett/Documents/Work/aws/serverless-stack-demo-api/node_modules/aws-sdk/lib/protocol/json.js:48:27)
at Request.callListeners (/Users/absett/Documents/Work/aws/serverless-stack-demo-api/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at Request.emit (/Users/absett/Documents/Work/aws/serverless-stack-demo-api/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/Users/absett/Documents/Work/aws/serverless-stack-demo-api/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/Users/absett/Documents/Work/aws/serverless-stack-demo-api/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/Users/absett/Documents/Work/aws/serverless-stack-demo-api/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Users/absett/Documents/Work/aws/serverless-stack-demo-api/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/Users/absett/Documents/Work/aws/serverless-stack-demo-api/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/Users/absett/Documents/Work/aws/serverless-stack-demo-api/node_modules/aws-sdk/lib/request.js:685:12)
at Request.callListeners (/Users/absett/Documents/Work/aws/serverless-stack-demo-api/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
at Request.emit (/Users/absett/Documents/Work/aws/serverless-stack-demo-api/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/Users/absett/Documents/Work/aws/serverless-stack-demo-api/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/Users/absett/Documents/Work/aws/serverless-stack-demo-api/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/Users/absett/Documents/Work/aws/serverless-stack-demo-api/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Users/absett/Documents/Work/aws/serverless-stack-demo-api/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/Users/absett/Documents/Work/aws/serverless-stack-demo-api/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/Users/absett/Documents/Work/aws/serverless-stack-demo-api/node_modules/aws-sdk/lib/request.js:685:12)
at Request.callListeners (/Users/absett/Documents/Work/aws/serverless-stack-demo-api/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
at callNextListener (/Users/absett/Documents/Work/aws/serverless-stack-demo-api/node_modules/aws-sdk/lib/sequential_executor.js:95:12)
at IncomingMessage.onEnd (/Users/absett/Documents/Work/aws/serverless-stack-demo-api/node_modules/aws-sdk/lib/event_listeners.js:269:13)
at IncomingMessage.emit (events.js:164:20)
at endReadableNT (_stream_readable.js:1054:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)
message: 'Requested resource not found',
code: 'ResourceNotFoundException',
time: 2018-05-09T15:12:35.034Z,
requestId: 'JP1ST06JJK9ICKBCU0LIRTGE1NVV4KQNSO5AEMVJF66Q9ASUAAJG',
statusCode: 400,
retryable: false,
retryDelay: 26.28053621862381 }
{
"statusCode": 500,
"headers": {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": true
},
"body": "{"status":false}"
}

Am I missing any configuration?

@abhisheksett When are you seeing this error?

I'm getting this error when I'm trying to create a note by following command:
serverless invoke local --function create --path mocks/create-event.json

@abhisheksett This seems like it is complaining about not finding your DynamoDB table. Can I see your create.js?

This issue was moved to https://discourse.serverless-stack.com/t/comments-add-a-create-note-api/84

This issue was moved to https://discourse.serverless-stack.com/t/comments-add-a-create-note-api/125

@jayair,
I just started my serverless framework tutorial and found this very useful so far. Thanks a bunch!
I'm running into this issue when I run:
serverless invoke local --function create --path mocks/create-event.json
Serverless: DOTENV: Loading environment variables from .env:
Syntax Error -------------------------------------------
SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at Object.parseJC [as parse] (/Users/tonyliu/.npm-global/lib/node_modules/serverless/node_modules/json-cycle/cycle.js:136:28)
at parse (/Users/tonyliu/.npm-global/lib/node_modules/serverless/lib/utils/fs/parse.js:22:15)
at /Users/tonyliu/.npm-global/lib/node_modules/serverless/lib/utils/fs/readFile.js:7:58
 For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

Get Support --------------------------------------------
Docs:          docs.serverless.com
Bugs:          github.com/serverless/serverless/issues
Issues:        forum.serverless.com
Your Environment Information ---------------------------
Operating System:          darwin
Node Version:              12.16.3
Framework Version:         1.71.3
Plugin Version:            3.6.12
SDK Version:               2.3.1
Components Version:        2.30.12

Please post this over on your forums!
https://discourse.serverless-stack.com

I'm unable to post on the forums as a new user for now so that's why I posted here....

Weird. I think it just got caught by the spam detection. I think I allowed it. Can you post in there now?

{
    "statusCode": 500,
    "headers": {
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Allow-Credentials": true
    },
    "body": "{\"status\":false}"
}

I had this error. Ii was because I forgot to create the table in DynamoDB


Designer doesn't seems to be working

Designer 'drag and drop' does it seems to be working in chrome, also you could specify minimum supported browser version.

Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

ID: cc13a127-253d-6438-52ed-319589d8d3ec
Version Independent ID: 9bcc413c-55cb-a0e0-8ca2-f111658076fe
Content: Building your first sample extension that uses new objects and extension objects - Business Central
Content Source: dev-itpro/developer/devenv-extension-example.md
Service: dynamics365-business-central
GitHub Login: @jswymer
Microsoft Alias: solsen

Hello, thanks for your feedback. System requirements can be found here. If you cannot make the Designer drag and drop work, please file a product bug using your usual support mechanism. Thanks.


chore(v2): better error message style

Motivation
Improve error message
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Try to simulate an error
Before

After

yes. So that its framework independent.


we should care about the revert of transfer func of the ERC20 tokens

https://github.com/darwinia-network/darwinia-bridge-sol/blob/53655320e06540c8748248fa61726b18ace4119c/contracts/issuing-backing/contracts/ethereum/Ethereum2DarwiniaBacking.sol#L213
If this reverted, all other events cannot be verified. Here we should use address.call.

The sub2eth v2 has no such problem.


Create a route that exports the entire Access table to csv for libcal to read

refs https://github.com/pulibrary/requests/issues/822
depends on #788 & #789
This an endpoint that should produce a single column CSV file with the netid of all the users that are allowed on campus.
/campus_access.csv

This is no longer needed.


[SP-6610] Backport of PPP-5166 - Use of Vulnerable Component: Compone…

…nts/jackson-databind 2.14.2 (Non OSGi upgrade) (10.2 Suite)

this will fail in wingman, this PR depends on new maven property in pentaho/maven-parent-poms#615

:x: Build failed in 1m 14s
Build command:
mvn clean verify -B -e -Daudit -Djs.no.sandbox

:exclamation: No tests found!
Errors:
Filtered log (click to expand)

script returned exit code 1

:information_source:  This is an automatic message

:x: Build failed in 1m 38s
Build command:
mvn clean verify -B -e -Daudit -Djs.no.sandbox

:exclamation: No tests found!
Errors:
Filtered log (click to expand)

script returned exit code 1

:information_source:  This is an automatic message

:x: Build failed in 2m 9s
Build command:
mvn clean verify -B -e -Daudit -Djs.no.sandbox

:exclamation: No tests found!
Errors:
Filtered log (click to expand)

script returned exit code 1

:information_source:  This is an automatic message

🐸 JFrog Frogbot

🐸 JFrog Frogbot

:warning: Build finished in 3h 24m 42s
Build command:
mvn clean verify -B -e -Daudit -Djs.no.sandbox

:no_entry: Failed Tests
:cloud_with_lightning_and_rain: 2 test(s) failed:
org.pentaho.ui.database.event.FragmentHandlerTest.org.pentaho.ui.database.event.FragmentHandlerTest (click to expand)
No more handles [gtk_init_check() failed]

org.pentaho.di.trans.step.mqtt.MQTTStreamSourceTest.testMQTTOpenException (click to expand)
Failed to bind to server socket: mqtt://localhost:34983 due to: java.net.BindException: Address already in use

Tests run: 5510, Failures: 2, Skipped: 23    Test Results

:information_source:  This is an automatic message

Failing tests look unrelated to the code changes. Merging!


fix for CALL gas prior to EIP-150

Fixes block 196647

Looking at the Frontier YP, I think there might be an edge case we are not considering from it. In case we are executing a CALL with callValue (u_2) ==0, our current startGas for the contract being called is gCap (as endowment==0). As we would be executing a block from Frontier then gCap would be the gas parameter (u_0 in the YP) but (at least according to the Frontier YP) it should be 0. Could there be something that I'm missing or maybe the clients implement something different?

@ntallar I'm not sure if I follow. The addend that is dependent on callValue is called CCALLXFER in frontier YP and CXFER in the new one. In both cases it is part of gExtra - frontier YP doesn't explicitly specify CEXTRA but its constituents are part of CCALL definition (subtract μs[0] and you get CEXTRA)
Does that clarify things or am I missing something?

Sorry, I think I didn't explain myself properly. What I'm comparing is the C_callgas function for the case that u_2 (in our code callValue)==0, before EIP150 it is always 0 (at least according to the YP) while after it, it is C_gascap. In our code it seems that we are only following the case after EIP150, being the starting gas C_gascap but maybe I'm missing something or the implementation in other clients differ from this.

Ah, _CCALLGAS yes, good catch! But does it even make sense? That would essentially disallow calling a contract when callValue is zero.

I am not seeing anything like that in geth or ethereumJ. Looks like they simply add the Gcallstipend when callValue != 0.

That's weird. But I agree that it makes more sense to do it as done in geth and ethereumJ  (which is probably why they did it that way) At least this YP difference simplifies our code

@ntallar This concludes our discussion: https://github.com/ethereum/yellowpaper/pull/181 😄

scala style fails on CI

other then that LGTM


Feature metamask multichain snap

(WIP)
ref: https://shapeshift.com/snap
Asset support via metamask
| LTC              |   ✅    |
| BCH              |   ✅    |
| DOGE             |   ✅    |
| ETH              |   ✅    |
| AVAX             |   ✅    |
| BSC              |   ✅    |
| COSMOS (ATOM)    |   ✅    |
| OP               |   ✅    |
| MATIC            |   ✅    |
| BNB              |  ❌    |
| THORCHAIN (RUNE) |   ✅    |```

This PR is a draft and not working yet, it was made for early feedback

Continued in #401


Migrate GitLab CI to GitHub Actions

Migration of the GitLab CI to GitHub Actions in scope of https://github.com/paritytech/ci_cd/issues/841

This PR replaces GitLab CI with similar jobs executed via GitHub Actions

!!! BEFORE MERGE
Setup environment master_and_tags and add there secrets DOCKERHUB_USERNAME and DOCKERHUB_PASSWORD
@kianenigma @PierreBesson should we keep existing GHA build.yml ?

Environment is created and secrets are set


TypeScript: img attribute types missing

It seems the generated TypeScript types no longer include crossorigin, decoding, elementtiming, fetchpriority, ismap, loading, referrerpolicy, role, srcset, and usemap, as of v0.13.3
It's true that the previous type definitions were too permissive however this may be a source of frustration. Let me know if you would like assistance.
Current workaround: use v0.13.2

Ugh, that's disappointing. Thanks for the report.
Do you know if there is an easy way for SanityImage to extend the default img element props in JSDoc to resolve this?

@jfgilmore Are you still available to assist on this?

@jfgilmore Are you still available to assist on this?
The earliest I can get to it is probably next week.

I have submitted #41 which hopefully resolves this. I have omitted fetchpriority due to it's experimental status and ismap as its use is not recommended (it's also not included in the default props for img elements in React).

Fixed in #41 (v0.13.4).


A few "scary" questions...

I'm somewhat new to CDRT's, and I was hoping you could give me an insight into how to use this library.

Is the unique identifier used for .applyInsert the same as the one inside the couple created by the remote .insert? Or should it be generated in some other way?

var lseq = require("lseqtree")

var a = new lseq(0)
var b = new lseq(1)

var ei = a.insert('A', 0)
var index = b.applyInsert(ei._e, ei._i) // <-- Correct?

Am I correct in assuming the index returned by .applyInsert is incremented by 1 because the "Begin" virtual leaf is always at index 0? The above example sets index to 1, even though intuition would have 'A' be inserted at index 0.

How do I create a human-readable text document from the tree? In the other direction, is there a more efficient way to generate a tree from an existing document than just doing "Insert" for every character?

Thanks for your patience, looking forward to any advice you can provide.

Also, is there any way to make the indexes by line/column instead of absolute offset?

Your snippet is correct.

I think (it was a long time ago) that you are again correct.
Identifiers are generated between two other identifiers. Consequently, the tree is initialized with two hidden identifiers: identifier_min and identifier_max. Thus, < " " , identifier_min> takes Index 0 from start.
I agree that the intuition would have 'A' inserted at index 0. At the time, I considered it as a shared structure without considering its usage. The indexes are the indexes of the "flattened" version of the tree. If I reworked it, I would probably switch to the behavior you mentioned.

The "scary" question! I wrote a decentralized editor using ace for the GUI but you have other options such as quill.js.

How do I create a human-readable text document from the tree?

By default, when the user types a character, the editor will automatically print it. Your job is to catch this event and create an identifier depending on the insertion index in the document.
Then, you have to send it to all members, i.e., a broadcast protocol is required, hence a membership protocol is required. When they receive the message, they must order the operations depending on the order these operations were generated, i.e., a form of causality tracking is required. (I leave this paragraph undetailled but I could detail more if you are interested)
When the operation is "causally ready" to be integrated, you apply the operation to the tree structure which will give you an index. You map this with the GUI (commonly using patches).

In the other direction, is there a more efficient way to generate a tree from an existing document than just doing "Insert" for every character?

Like a.insert('This is the document.', 0) ?
It is possible. Instead of generating an identifier for each character, you could generate an identifier for a string. LogootSplit does that. LSEQTree does not implement it though. In this approach, you have to be careful and split the strings when need be, e.g., a.insert('whole ' 12) splits This is the document in This is the  and document. resulting in This is the whole document.. This is a trade-off, for you generate less identifiers (gain in CPU and memory) but when splits happen it becomes more costly. In practice, it is probably a significant improvement.

I don't think there is any way. You could instantiate 1 LSEQTree per line but that would not be good... With ace, there is a function that converts line/column to absolute offset, but I didn't check its complexity.

Awesome answers, just a few clarifications...

The behavior is fine (and probably more "technically correct"), I just wanted to ensure my understanding was correct.

By "order the operations depending on the order these operations were generated", you mean that operations originating from the same site must be ordered, right? You don't mean some kind of global causality (which I thought was impossible?). ie) All of Alice's inserts are in order relative to Alice's other inserts, but maybe not relative to Bob's. A1 -> A2 -> B1  is just as valid as A1 -> B1 -> A2

I'll take a closer look at CRATE, seems to be the best place to start.
As for multiple character inserts... Logootsplit looks good, but doesn't Logoot have an issue with unbounded identifiers? I might be wrong, but I was under the assumption that LSEQ was an improvement (sublinear memory growth vs linear). Or is the difference insignificant in practice?

I figured out that I can convert line/ch to offset (and back) by keeping track of the newline characters in the document and moving these indexes when I insert/delete. Seems pretty fast with binary search and isn't limited to any editor implementation. So that should be fine.

Thanks again.

Here you choose the causality tracking mechanism that fits best the scale of your system  and the desired user experience.

scale of the system: with 10 members you can afford to send the full version vector with each operation; with 100 members it is not practicable)
user experience: with a version vector you can order all operations, thus if Alice types H , Bob receives it and types i, Carol receives the later but since she did not yet receive H, she cannot integrate i which is nice because the insertion of i only makes sense if the H exists. Also, the removal of a particular character always follows its insertion by design.   However, if you cannot afford the full version vector, you can only track a subset of required operations before integration. Here, it is up to you. In Crate, I chose to integrate all insertions as soon as they arrive (when Carol receives i she integrates it immediately without waiting for the H) and removals wait for their respective insertion. But you could put additional constraints on insertion, eg wait for the insertion that precedes (in the document) the current one (i's integration follows H).

Logoot have an issue with unbounded identifiers?

They are bounded but grow linearly. They may grow slowly --still linearly-- depending on the insertions order and positions.

Logootsplit looks good, but doesn't Logoot have an issue with unbounded identifiers?

Logoot has the aforementioned issue, but the "Split" part is an orthogonal improvement. Even though LogootSplit as a whole is introduced like a new CRDT, Logoot and Split are disjoint. Logoot provides identifiers, and Split allows the CRDT to work directly on strings. LSeqSplit could exist and it would benefit from both improvements.

Or is the difference insignificant in practice?
It is difficult to answer precisely to this question, for it depends of the documents (positions of insertion and number of insertions), and the configuration of each approach. Since the space complexity of identifiers are different, there is not an equivalent configuration between Logoot and LSeq that would work for any document.

Since LSeq has a better complexity, it is "safer" when the size of the document grows. Plus, you can start with small identifiers.

Great!

You are welcome.


New Release Checklist - v1.4.0

Description
This issue is tracking steps to complete a release ensuring all artifacts are correctly produced. This covers both automated tasks and manual tasks.
Release
Manual steps are instructions that need to be taken in order to have a full release on all associated repos. Validation steps consist of checklist of items to verify, to ensure all reqiuirements and releases have gone without problems and that the correct assets are created needed for the manual steps.
Validation Steps

[x] Builds complete successfully
[x] Release actions complete successfully
[x] Assets — ensure the following assets have been created by the release actions and are uploaded as assets in the release

[x] Debian Package, named okapi_X.X.0_amd64.deb
[x] Okapi tarball (for Homebrew), named okapi-X.X.0.tar.gz
[x] Okapi vendored tarball (for Homebrew), named okapi-vendor-X.X.0.tar.gz
[x] Library bundle named libs.zip

[x] Package Releases — validate if packages have been correctly released

[x] nuget.org
[x] npmjs.com
[x] pypi.org
[x] rubygems.org

Manual Steps

[x] Github Release — create a new release following the semantic versioning guidelines. The next available version should increase either the Major or Minor version, following the semver recommendations. Patch should be set to 0. This allows individual languages to publish hotfixes under the same version with new patch. An example version format is v1.2.0.

[x] Ensure code contributions and commits are included in the release description, either by utilizing the GitHub automatic options or entering them manually.

[x] Swift Release — create new release in associated repository for Swift package at trinsic-id/okapi-swift. The release version in this repo follows a pattern that doesn't include leading v. Example release format is 1.2.0.
[ ] External Tools

[x] Homebrew — to create a new tap, follow the instructions at trinsic-id/homebrew-tap by making a new PR with the required information. This step depends on a release asset package.
[ ] Windows Package Manager (winget) — TODO: Add details
[x] NixOS — TODO: Add details

[x] Samples — if required, code samples at https://github.com/trinsic-id/okapi-examples should be updated to match the version
[x] Release announced to Trinsic Team

https://github.com/microsoft/winget-pkgs/pull/49952/files


Uteco

@AlexDark3 lib/domains/uteco.txt: this request has an incorrect file path format, please ensure that you are familiar with     this repository rules located at the bottom of this page and change     your request accordingly. If you don't know how to change request, close it and open a new one.     If you are not able to make the pull request according the instructions, please send us an email to<EMAIL_ADDRESS>Please mention this request URL in the message.

@AlexDark3 Thank you for your patience while waiting for a review and processing your request. Pull request merged.


Add documentation for developers

It would be helpful if we had some documentation to help developers get up and running quickly. Looks like we're using Jekyll with a portable docker environment...

(The enhancement label seems to have been added automatically and I don't have permissions to remove it.)


Allow hiding of user records from leaderboard

Quick triage comment: nice-to-have, but really not that big a deal in the grand scheme of things.


Flaky userId/sessionId on the client side after logging in

Preliminary Checks

[X] I have reviewed the documentation: https://clerk.com/docs, and specifically https://clerk.com/docs/references/nextjs/read-session-data
[X] I have searched for existing issues: https://github.com/clerk/javascript/issues
[X] I have not already reached out to Clerk support via email or Discord (if you have, no need to open an issue here)
[X] This issue is not a question, general help request, or anything other than a bug report directly related to Clerk. Please ask questions in our Discord community: https://clerk.com/discord.

Reproduction
https://github.com/lovincyrus/coolection/blob/cyrus/clerk-auth-bug/app/components/header.tsx
Publishable key
pk_test_bmF0aW9uYWwtZ3JpZmZvbi00Ny5jbGVyay5hY2NvdW50cy5kZXYk
Description
Recording: https://www.loom.com/share/9c23de08c8264ed5bb5d51b5f89d9e7a

Steps to reproduce:

Run the app locally
Log in via Google auth
Pay attention to the sign out button in the header. The userId and sessionId would sometimes be undefined upon logging in.

Expected behavior:
The custom sign out button should always fire the signOut() and sign out the current user when clicked.
Actual behavior:
The custom sign out button isn't being fired because the userId / sessionId isn't available yet.
Environment
System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 8.01 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.20.2 - ~/Library/Caches/fnm_multishells/22961_1716262993246/bin/node
    Yarn: 1.22.21 - /opt/homebrew/bin/yarn
    npm: 10.5.0 - ~/Library/Caches/fnm_multishells/22961_1716262993246/bin/npm
    pnpm: 8.15.4 - ~/Library/pnpm/pnpm
    bun: 1.0.26 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: <IP_ADDRESS>
    Chrome: 125.0.6422.60
    Safari: 17.4.1
  npmPackages:
    @clerk/clerk-react: ^5.1.0 => 5.1.0
    @clerk/nextjs: ^5.0.12 => 5.0.12
    @piotr-cz/swr-idb-cache: ^1.0.3 => 1.0.3
    @prisma/client: ^5.13.0 => 5.13.0
    @radix-ui/react-context-menu: ^2.1.5 => 2.1.5
    @radix-ui/react-dialog: ^1.0.5 => 1.0.5
    @radix-ui/react-label: ^2.0.2 => 2.0.2
    @radix-ui/react-scroll-area: ^1.0.5 => 1.0.5
    @radix-ui/react-slot: ^1.0.2 => 1.0.2
    @types/node: ^20.12.7 => 20.12.7
    @types/react: ^18 => 18.3.1
    @types/react-dom: ^18 => 18.3.0
    @vercel/analytics: ^1.2.2 => 1.2.2
    @vercel/speed-insights: ^1.0.10 => 1.0.10
    autoprefixer: ^10.4.19 => 10.4.19
    cheerio: 1.0.0-rc.12 => 1.0.0-rc.12
    class-variance-authority: ^0.7.0 => 0.7.0
    clsx: ^2.1.1 => 2.1.1
    eslint: ^8 => 8.57.0
    eslint-config-next: 14.2.3 => 14.2.3
    eslint-plugin-simple-import-sort: ^12.1.0 => 12.1.0
    eslint-plugin-unused-imports: ^3.1.0 => 3.1.0
    framer-motion: ^11.1.9 => 11.1.9
    lucide-react: ^0.376.0 => 0.376.0
    next: 14.2.3 => 14.2.3
    node-fetch: ^3.3.2 => 3.3.2
    normalize-url: ^8.0.1 => 8.0.1
    openai: ^4.39.0 => 4.39.0
    postcss: ^8.4.38 => 8.4.38
    prettier: ^3.2.5 => 3.2.5
    prettier-plugin-tailwindcss: ^0.5.14 => 0.5.14
    prisma: ^5.13.0 => 5.13.0
    react: ^18 => 18.3.1
    react-dom: ^18 => 18.3.1
    reakeys: ^2.0.2 => 2.0.2
    sonner: ^1.4.41 => 1.4.41
    swr: ^2.2.5 => 2.2.5
    tailwind-merge: ^2.3.0 => 2.3.0
    tailwindcss: ^3.4.3 => 3.4.3
    ts-node: ^10.9.1 => 10.9.2
    typescript: ^5.4.5 => 5.4.5
    use-debounce: ^10.0.0 => 10.0.0
    uuidv4: ^6.2.13 => 6.2.13

Update:
I suspected that the flakiness was caused by this codeblock.
I have added a webhook to synchronize user metadata with the database instead, since then, I have not encountered any more missing userId/sessionId errors or issues with signOut() not firing.
https://github.com/clerk/javascript/assets/1021101/10c989fe-fd24-4e3e-9b2d-9b71b81c5ff1


The "set as default" option causes malfunctions to the Windows file explorer

Description
When I activate the "set as default" setting, the original file explorer will not be able to open external devices such as phones or tablets.
When I double click on t he device, the windows file explorer will open a new window in the User documents.
This issue occurs on Windows 11 when I connect an android phone. I haven't tested it with Apple devices.
The issue behavior is was filmed and is present right at the beginning of this video: https://www.youtube.com/watch?v=h1svlSPJXYc
The issue does not occur anymore if the "set as default" from the Files explorer is turned off.
Steps To Reproduce

Set Files as the default file explorer through the experimental options.
Connect an android phone.
Try to open the device contents using the Windows File Explorer.
Notice the issue occurring.

Steps to fix
Correct the action that happens when opening the device contents using the Windows File Explorer, while Files is the default explorer.
Files Version
<IP_ADDRESS>
Windows Version
Windows 11 22H2 22621.900
Relevant Assets/Logs
debug.log

I can't access the video (you can try uploading directly to GitHub) but the option to replace File Explorer will prevent you from using it in certain circumstances.

I can't access the video (you can try uploading directly to GitHub) but the option to replace File Explorer will prevent you from using it in certain circumstances.

Uploading video now:
https://user-images.githubusercontent.com/10486881/207186450-2291f7c4-c07a-43f4-9514-c28ac1cd920a.mp4

This is one of the side effects of replacing File Explorer, if this behavior is an issue for you, we recommend turning off the experimental setting for now.