claudiajs / claudia

Deploy Node.js projects to AWS Lambda and API Gateway easily
https://claudiajs.com
MIT License
3.8k stars 276 forks source link

Claudia update failing API Gateway #183

Closed BrentonWatt closed 5 years ago

BrentonWatt commented 5 years ago

As of this morning running claudia update on a lambda built with API Builder doesn't work. My local machine was running claudia v5.3.0 and I could successfully update my lambda. My pipeline was getting the latest version on every run, v5.4.0. As of this morning the pipeline started failing. I updated my local machine to 5.4.0 and got the same error. I rolled back to 5.3.0 and now I still have the same error. (It's worth noting, this only affects my APIBuilder lambdas, the other lambdas are fine)

Deploy lambda and connect with API Gateway

The reason that it's not working even after a version roll-back leads me to believe a dependancy is causing the issue. If I'm missing something painfully obvious, feel free to point it out and close the issue

BrentonWatt commented 5 years ago

At the time of this posting the AWS SDK was updated 12 hours ago. I'm not sure if the issue is there.

pjay79 commented 5 years ago

I am getting a similar error... claudia 5.4, aws-serverless-express 3.3.5

`claudia create --handler lambda.handler --deploy-proxy-api --region us-east-1 packaging files npm install -q --no-audit --production npm WARN server@1.0.0 No description npm WARN server@1.0.0 No repository field.

validating package npm dedupe -q --no-package-lock creating REST API apigateway.setAcceptHeader { BadRequestException: Invalid request input at Object.extractError (/usr/local/lib/node_modules/claudia/node_modules/aws-sdk/lib/protocol/json.js:51:27) at Request.extractError (/usr/local/lib/node_modules/claudia/node_modules/aws-sdk/lib/protocol/rest_json.js:55:8) at Request.callListeners (/usr/local/lib/node_modules/claudia/node_modules/aws-sdk/lib/sequential_executor.js:106:20) at Request.emit (/usr/local/lib/node_modules/claudia/node_modules/aws-sdk/lib/sequential_executor.js:78:10) at Request.emit (/usr/local/lib/node_modules/claudia/node_modules/aws-sdk/lib/request.js:683:14) at Request.transition (/usr/local/lib/node_modules/claudia/node_modules/aws-sdk/lib/request.js:22:10) at AcceptorStateMachine.runTo (/usr/local/lib/node_modules/claudia/node_modules/aws-sdk/lib/state_machine.js:14:12) at /usr/local/lib/node_modules/claudia/node_modules/aws-sdk/lib/state_machine.js:26:10 at Request. (/usr/local/lib/node_modules/claudia/node_modules/aws-sdk/lib/request.js:38:9) at Request. (/usr/local/lib/node_modules/claudia/node_modules/aws-sdk/lib/request.js:685:12)`

BrentonWatt commented 5 years ago

@pjay79 According to @gojko it is an issue with the AWS-SDK dependancy, there was an update to it last night and it's caused a backwards compatibility issue. I'm waiting for more feedback. You can follow here if you want https://gitter.im/claudiajs/claudia

gojko commented 5 years ago

I narrowed this down to a single method, but the bug is in aws-sdk, so I don't really have a way of fixing it. I logged it as https://github.com/aws/aws-sdk-js/issues/2588. Meanwhile, downgrade your aws-sdk to the previous version (npm i aws-sdk@2.423.0 -S) and it should work

BrentonWatt commented 5 years ago

@gojko how would we do this in a pipeline deployment scenario because I assume we’ll have to run “npm I aws-sdk@2.423.0” inside Claudia’s globally installed location? Or would we just do it at a project level?

gojko commented 5 years ago

@BrentonWatt claudia needs a much older version in its package.json, so your project is likely asking for a newer one (or just asking for the latest one). try downgrading the requirements in your project to that aws sdk until they fix the bug

gojko commented 5 years ago

I have a potential fix for this (https://github.com/claudiajs/claudia/commit/d52e99d34254ed9644d8119a4f28299737c91898) and now running integration tests to check if any other regression bugs were introduced in the last aws-sdk release. expect a new version to come out in a few hours once the tests pass

gojko commented 5 years ago

this seems to be a much wider bug than I initially thought, so we'll have to wait for aws-sdk to fix it. they seem to have a patch in process now (https://github.com/aws/aws-sdk-js/issues/2588)

gojko commented 5 years ago

aws just released 2.426.0 that fixes this issue, so just update to latest aws-sdk and the problem should no longer appear

gojko commented 5 years ago

claudia 5.4.1 is now on NPM, using the fixed version of aws-sdk, so you should no longer have to use the workaround