Skip to content

sls deploy function -f <function> does not work - TypeError: Cannot read property 'runtime' of undefinedΒ #605

Closed
@aelsnz

Description

@aelsnz

If you are using the latest serverless (I have tried 2.34 and above) with this plugin and try and update one function you get TypeError: Cannot read property 'runtime' of undefined

Any ideas why this fails if the plugin is enabled? This used to work well in earlier versions.
Any help or ideas to solve this would be awesome.

Example output:

$ sls deploy function -f hello --stage ae --region ap-southeast-2

 Type Error ----------------------------------------------

  TypeError: Cannot read property 'runtime' of undefined
      at /Users/demo/test/node_modules/serverless-python-requirements/lib/pip.js:609:15
      at Array.filter (<anonymous>)
      at ServerlessPythonRequirements.installAllRequirements (/Users/demo/test/node_modules/serverless-python-requirements/lib/pip.js:608:8)
      at ServerlessPythonRequirements.tryCatcher (/Users/demo/test/node_modules/bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (/Users/demo/test/node_modules/bluebird/js/release/promise.js:547:31)
      at Promise._settlePromise (/Users/demo/test/node_modules/bluebird/js/release/promise.js:604:18)
      at Promise._settlePromise0 (/Users/demo/test/node_modules/bluebird/js/release/promise.js:649:10)
      at Promise._settlePromises (/Users/demo/test/node_modules/bluebird/js/release/promise.js:729:18)
      at _drainQueueStep (/Users/demo/test/node_modules/bluebird/js/release/async.js:93:12)
      at _drainQueue (/Users/demo/test/node_modules/bluebird/js/release/async.js:86:9)
      at Async._drainQueues (/Users/demo/test/node_modules/bluebird/js/release/async.js:102:5)
      at Immediate.Async.drainQueues [as _onImmediate] (/Users/demo/test/node_modules/bluebird/js/release/async.js:15:14)
      at processImmediate (internal/timers.js:461:21)

     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 ---------------------------
     Operating System:          darwin
     Node Version:              14.16.1
     Framework Version:         2.37.1
     Plugin Version:            4.5.3
     SDK Version:               4.2.2
     Components Version:        3.9.0

You can easily duplicate this using the example api - https://github.com/serverless/examples/tree/master/aws-python-rest-api with few small updates - see example serverless.yaml below.

service: test-api
frameworkVersion: '2'

plugins:
  - serverless-python-requirements

custom:
  pythonRequirements:
    dockerizePip: true
    slim: true
    layer:
      compatibleRuntimes:
        - python3.8

provider:
  name: aws
  runtime: python3.8
  lambdaHashingVersion: '20201221'

package:
  individually: true
  patterns:
    - '!*.txt'
    - '!*.md'
    - '!*.json'
    - '!node_modules/**'

functions:
  hello:
    handler: handler.hello
    layers:
      - { Ref: PythonRequirementsLambdaLayer }
    events:
      - http:
          path: /
          method: get

Example requirements.txt with a module in there.

jsonpickle

Environment Details

serverless-python-requirements version: 5.1.1

Environment overview:
     Operating System:          darwin
     Node Version:              14.16.1
     Framework Version:         2.37.1
     Plugin Version:            4.5.3
     SDK Version:               4.2.2
     Components Version:        3.9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions