Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot read property 'match' of undefined #49

Open
mattmeye opened this issue Jan 29, 2019 · 12 comments
Open

Error: Cannot read property 'match' of undefined #49

mattmeye opened this issue Jan 29, 2019 · 12 comments

Comments

@mattmeye
Copy link

mattmeye commented Jan 29, 2019

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:
      - '*/*'
@mark-omarov
Copy link

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
Copy link

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.

@AbhilashKanimilli
Copy link

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

@Bookrage001
Copy link

Bookrage001 commented Aug 22, 2019

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

@joefhall
Copy link

joefhall commented Sep 2, 2019

@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

@jeanlescure
Copy link

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

@salvadorplj
Copy link

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

@mooyoul
Copy link

mooyoul commented May 24, 2020

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.

@Christop406
Copy link

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

@ThiagoFelippi
Copy link

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

@julienvallet
Copy link

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

@michaelpanik
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests