serverless: Unable to deploy single lambda function for version 1.52.1

sls deploy -f “function_name” is not working throwing and exception

My serverless version is: Framework Core: 1.52.1 Plugin: 3.0.0 SDK: 2.1.1 sls deploy -f function_name is not working it throws and errors the complete trackback would be TypeError: Cannot read property 'artifact' of undefined at ServerlessPythonRequirements.BbPromise.bind.then.then.then (/home/mahesh/shuttle/H2OLambda/pythonh20lambda/node_modules/serverless-python-requirements/index.js:176:48)

Any update on this would be appreciated. Thank you

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 42
  • Comments: 47 (8 by maintainers)

Commits related to this issue

Most upvoted comments

@ovunccetin Your workaround can be shorten to just:

hello:
    # ...
    package: {}

I found a workaround but I’m not sure about the side effects.

The problem is the following line (line # 176 in my version) in serverless-python-requirements/index.js file:

arguments[1].functionObj && 
    arguments[1].functionObj.package.artifact.

It simply assumes the existence of package.artifact path in your function definition in serverless.yml.

As a work around I added "package: artifact: " to my function as follows and it worked:

hello:
    handler: hello.handler
    package:
      artifact:
    events:
      - http:
          path: hello
          method: get

Again, I’m not sure if this breaks anything else. I have just tried an individual function deployment and it worked. But I didn’t make a detailed test.

One solution I found is to downgrade it to version Framework Core: 1.51.0 Plugin: 1.3.11 SDK: 2.1.2

  1. npm uninstall -g serverless
  2. npm install -g serverless@1.51.0

@ovunccetin and @lephuongbg confirming your workaround also works for serverless 1.65.0.

new update 1.57.0 did not solve the problem , still have to downgrade it for resolving this issue

1 npm uninstall -g serverless
2  npm install -g serverless@1.51.0

@ Maheshkumar094 thanks for the solution

If this is an issue with serverless-python-requirements it is one that has some dependencies/interactions with serverless itself, in that it is fixed by installing an earlier version of serverless (as described by @satejsarker ) and then reinstalling serverless-python-requirements.

The fact that it seems to happen with PHP functions as well (see above comment) suggests this is not solely an issue with serverless-python-requirements.

From those posting config snippets so far, this is likely an issue in the serverless-python-requirements plugin.

There is an issue open in that project tracking this: https://github.com/UnitedIncome/serverless-python-requirements/issues/414

Unless anyone is experiencing this issue is not using serverless-python-requirements it probably makes sense to track it over there.

functions:
  handler:
    handler: functions/handler.handler
    package: {} # This fixes the issue.
    events:
      - http:
          path: /map
          method: post
          cors: true

ovunccetin’s workaround works great, so far no drawbacks.