serverless-apigw-binary icon indicating copy to clipboard operation
serverless-apigw-binary copied to clipboard

Error: Cannot read property 'match' of undefined

Open mattmeye opened this issue 6 years ago • 12 comments

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:
      - '*/*'

mattmeye avatar Jan 29 '19 15:01 mattmeye

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!

mark-omarov avatar Mar 25 '19 13:03 mark-omarov

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.

mark-omarov avatar Mar 25 '19 13:03 mark-omarov

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 () at BinarySupport.getApiId (D:\MyPgGuru\serverless-image-rendering\node_modules\serverless-apigw-binary\src\index.js:14:12) at BinarySupport.afterDeploy (D:\MyPgGuru\serverless-image-rendering\node_modules\serverless-apigw-binary\src\index.js:59:17) at BbPromise.reduce (C:\Users\Abhi\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:446:55) From previous event: at PluginManager.invoke (C:\Users\Abhi\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:446:22) at PluginManager.run (C:\Users\Abhi\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:477:17) at variables.populateService.then (C:\Users\Abhi\AppData\Roaming\npm\node_modules\serverless\lib\Serverless.js:110:33) at runCallback (timers.js:705:18) at tryOnImmediate (timers.js:676:5) at processImmediate (timers.js:658:5) at process.topLevelDomainCallback (domain.js:120:23) From previous event: at Serverless.run (C:\Users\Abhi\AppData\Roaming\npm\node_modules\serverless\lib\Serverless.js:97:6) at serverless.init.then (C:\Users\Abhi\AppData\Roaming\npm\node_modules\serverless\bin\serverless:43:28) at C:\Users\Abhi\AppData\Roaming\npm\node_modules\serverless\node_modules\graceful-fs\graceful-fs.js:111:16 at C:\Users\Abhi\AppData\Roaming\npm\node_modules\serverless\node_modules\graceful-fs\graceful-fs.js:45:10 at FSReqWrap.oncomplete (fs.js:141:20) From previous event: at initializeErrorReporter.then (C:\Users\Abhi\AppData\Roaming\npm\node_modules\serverless\bin\serverless:43:6) at runCallback (timers.js:705:18) at tryOnImmediate (timers.js:676:5) at processImmediate (timers.js:658:5) at process.topLevelDomainCallback (domain.js:120:23) From previous event: at C:\Users\Abhi\AppData\Roaming\npm\node_modules\serverless\bin\serverless:28:46 at Object. (C:\Users\Abhi\AppData\Roaming\npm\node_modules\serverless\bin\serverless:65:4) at Module._compile (internal/modules/cjs/loader.js:689:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10) at Module.load (internal/modules/cjs/loader.js:599:32) at tryModuleLoad (internal/modules/cjs/loader.js:538:12) at Function.Module._load (internal/modules/cjs/loader.js:530:3) at Function.Module.runMain (internal/modules/cjs/loader.js:742:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)

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}/*'

AbhilashKanimilli avatar May 31 '19 06:05 AbhilashKanimilli

I resolved this by installing the package into npm npm install serverless-apigw-binary also may complain about the run time of nodejs6.10

Bookrage001 avatar Aug 22 '19 07:08 Bookrage001

@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

joefhall avatar Sep 02 '19 16:09 joefhall

Just as @joefhall this problem persists even after following @Bookrage001's suggestion

jeanlescure avatar Sep 11 '19 22:09 jeanlescure

Same this problem persists even after following @Bookrage001's suggestion

salvadorplj avatar Sep 19 '19 16:09 salvadorplj

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.

mooyoul avatar May 24 '20 23:05 mooyoul

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 :)

Christop406 avatar Dec 09 '20 19:12 Christop406

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

ThiagoFelippi avatar Apr 04 '21 22:04 ThiagoFelippi

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:
   - '*/*'

julienvallet avatar Feb 09 '22 10:02 julienvallet

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:
            - '*/*'

michaelpanik avatar Dec 28 '23 17:12 michaelpanik