serverless-apigw-binary
serverless-apigw-binary copied to clipboard
Error: Cannot read property 'match' of undefined
hello, i get the following error during sls deploy:
...
layers:
None
Serverless: [AWS cloudformation 200 0.104s 0 retries] describeStacks({ StackName: 'xxx-home-dev' })
Type Error ---------------------------------------------
Cannot read property 'match' of undefined
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Stack Trace --------------------------------------------
TypeError: Cannot read property 'match' of undefined
at provider.request.then.resp (/builds/xxx/home/node_modules/serverless-apigw-binary/src/index.js:19:30)
From previous event:
at resolve (/builds/xxx/home/node_modules/serverless-apigw-binary/src/index.js:15:122)
at new Promise (<anonymous>)
at BinarySupport.getApiId (/builds/xxx/home/node_modules/serverless-apigw-binary/src/index.js:14:12)
at BinarySupport.afterDeploy (/builds/xxx/home/node_modules/serverless-apigw-binary/src/index.js:59:17)
at BbPromise.reduce (/builds/xxx/home/node_modules/serverless/lib/classes/PluginManager.js:391:55)
From previous event:
at PluginManager.invoke (/builds/xxx/home/node_modules/serverless/lib/classes/PluginManager.js:391:22)
at PluginManager.run (/builds/xxx/home/node_modules/serverless/lib/classes/PluginManager.js:422:17)
at variables.populateService.then.then (/builds/xxx/home/node_modules/serverless/lib/Serverless.js:111:33)
at processImmediate (timers.js:632:19)
at process.topLevelDomainCallback (domain.js:120:23)
From previous event:
at Serverless.run (/builds/xxx/home/node_modules/serverless/lib/Serverless.js:98:6)
at serverless.init.then (/builds/xxx/home/node_modules/serverless/bin/serverless:43:28)
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information -----------------------------
OS: linux
Node Version: 11.8.0
Serverless Version: 1.36.3
serverless.yml
custom:
...
apigwBinary:
types:
- '*/*'
Hi there! I'm getting the following error during deployment:
Type Error ---------------------------------------------
Cannot read property 'types' of undefined
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 -----------------------------
OS: darwin
Node Version: 9.10.1
Serverless Version: 1.39.1
serverless.yml
custom:
apigwBinary:
types:
- 'image/png'
I'd really love you to take a look at possible solution.
Highly appreciated!
I've found the problem and it's not related to the library. My case can be closed since my problem relative to our deployer that doesn't apply any custom settings from serverless.yml.
Need help. I get the following error during the serverless deploy.
Type Error ---------------------------------------------
Cannot read property 'match' of undefined
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Stack Trace --------------------------------------------
TypeError: Cannot read property 'match' of undefined
at provider.request.then.resp (D:\MyPgGuru\serverless-image-rendering\node_modules\serverless-apigw-binary\src\index.js:19:30)
From previous event:
at resolve (D:\MyPgGuru\serverless-image-rendering\node_modules\serverless-apigw-binary\src\index.js:15:122)
at new Promise (
My serverless.yml:
service: serverless-image-rendering custom: apigwBinary: types: - '/' BUCKET: XXXXXXX provider: name: aws runtime: nodejs6.10 stage: dev region: ap-south-1 timeout: 5 # optional, in seconds, default is 6 role: ImageRenderingRole environment: BUCKET: XXXXXXX plugins:
- serverless-apigw-binary
- serverless-apigwy-binary
functions:
resizeImage:
handler: handler.resizeImage
events:
- http:
path: resize-image
method: get
contentHandling: CONVERT_TO_BINARY
resources:
Resources:
ImageRenderingRole:
Type: AWS::IAM::Role
Properties:
RoleName: ${self:service}-S3-ACCESS
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: ${self:service}-s3-access PolicyDocument: Version: "2012-10-17" Statement: - Effect: Allow Action: - "s3:GetObject" Resource: - 'arn:aws:s3:::${self:custom.BUCKET}/*'
- http:
path: resize-image
method: get
contentHandling: CONVERT_TO_BINARY
resources:
Resources:
ImageRenderingRole:
Type: AWS::IAM::Role
Properties:
RoleName: ${self:service}-S3-ACCESS
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
Policies:
I resolved this by installing the package into npm
npm install serverless-apigw-binary
also may complain about the run time of nodejs6.10
@InkFaust could you let me know how you solved this problem in your case? I'm running into the same issue. (@Bookrage001's suggestion above of installing the package using npm doesn't solve it for me unfortunately.)
Thanks
Just as @joefhall this problem persists even after following @Bookrage001's suggestion
Same this problem persists even after following @Bookrage001's suggestion
I faced this issue and i just realized that i've accidentally removed api gateway trigger from my serverless.yml. After re-adding api gateway trigger (functions/events/http), It works just like before.
As dumb as this probably sounds, I was able to fix this by removing serverless-apigw-binary
from my serverless.yml
and dependencies. Turns out if you no longer have a lambda function that needs to serve binary files, there's no reason to have this package installed :)
Some libraries need to reinstall before deploy, try to add pre and post prefix and remove node_modules and reinstall with s3 operational system and node version, something like that:
"predeploy:hlg": "rm -rf node_modules && rm -rf package-lock.json && npm install --plataform linux --arch=x64 --target=12.21.0",
"deploy:hlg": "sls deploy,
"postdeploy:hlg": "rm -rf node_modules && npm install"
Obs: Verify if aws-multipart-parser a dependency, not a devdependencies, this can accuse an error too
Since v1.42 the serverless framework supports binary media type responses, so serverless-apigw-binary
is no longer necessary (https://www.serverless.com/blog/framework-release-v142)
provider:
apiGateway:
binaryMediaTypes:
- '*/*'
Since v1.42 the serverless framework supports binary media type responses, so
serverless-apigw-binary
is no longer necessary (https://www.serverless.com/blog/framework-release-v142)provider: apiGateway: binaryMediaTypes: - '*/*'
Only thing here is make sure to mind the indent under apiGateway:
provider:
apiGateway:
binaryMediaTypes:
- '*/*'