serverless / serverless-python-requirements

⚡️🐍📦 Serverless plugin to bundle Python packages
MIT License
1.11k stars 290 forks source link

Function Docker Image: ERR_INVALID_ARG_TYPE #774

Open oborchers opened 1 year ago

oborchers commented 1 year ago

Are you certain it's a bug?

Is the issue caused by a plugin?

Are you using the latest v3 release?

Is there an existing issue for this?

Issue description

If I try to provide an image for a function with name, command, and entryPoint I am unable to deploy the function.

If I remove all image related stuff and just provide and entrypoint I am able to deploy:

functions:
  aggregation:
    handler: handler_aggregation.handler_aggregation
    module: commons
    events:
      - httpApi:
          path: /get/aggregation
          method: get

Service configuration (serverless.yml) content

service: aggregation

frameworkVersion: '3'

provider:
  name: aws
  runtime: python3.8
  region: eu-west-1
  memorySize: 256
  ecr:
    images:
      baseimage:
        path: ./

functions:
  aggregation:
    image:
      name: baseimage
      command:
      - handler_aggregation.handler_aggregation
      entryPoint:
      - '/lambda-entrypoint.sh'
    events:
      - httpApi:
          path: /get/aggregation
          method: get

plugins:
  - serverless-python-requirements

Command name and used flags

STAGE=development sls deploy

Command output

Environment: darwin, node 19.7.0, framework 3.27.0 (local) 3.30.1v (global), plugin 6.2.3, SDK 4.3.2
Credentials: Local, environment variables
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
    at readFile (node:fs:393:10)
    at go$readFile (/Users/oliverborchers/Desktop/Programming.nosync/datapipelines/video_metrics/node_modules/graceful-fs/graceful-fs.js:118:14)
    at Object.readFile (/Users/oliverborchers/Desktop/Programming.nosync/datapipelines/video_metrics/node_modules/graceful-fs/graceful-fs.js:115:12)
    at Object.readFile (/Users/oliverborchers/Desktop/Programming.nosync/datapipelines/video_metrics/node_modules/universalify/index.js:5:57)
    at Object.tryCatcher (/Users/oliverborchers/Desktop/Programming.nosync/datapipelines/video_metrics/node_modules/bluebird/js/release/util.js:16:23)
    at Object.ret [as readFileAsync] (eval at makeNodePromisifiedEval (/Users/oliverborchers/Desktop/Programming.nosync/datapipelines/video_metrics/node_modules/bluebird/js/release/promisify.js:184:12), <anonymous>:14:23)
    at injectRequirements (/Users/oliverborchers/Desktop/Programming.nosync/datapipelines/video_metrics/node_modules/serverless-python-requirements/lib/inject.js:23:6)
    at ServerlessPythonRequirements.injectAllRequirements (/Users/oliverborchers/Desktop/Programming.nosync/datapipelines/video_metrics/node_modules/serverless-python-requirements/lib/inject.js:145:13)
    at ServerlessPythonRequirements.<anonymous> (/Users/oliverborchers/Desktop/Programming.nosync/datapipelines/video_metrics/node_modules/serverless-python-requirements/index.js:222:43)
    at ServerlessPythonRequirements.tryCatcher (/Users/oliverborchers/Desktop/Programming.nosync/datapipelines/video_metrics/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/oliverborchers/Desktop/Programming.nosync/datapipelines/video_metrics/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/oliverborchers/Desktop/Programming.nosync/datapipelines/video_metrics/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/oliverborchers/Desktop/Programming.nosync/datapipelines/video_metrics/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/oliverborchers/Desktop/Programming.nosync/datapipelines/video_metrics/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/oliverborchers/Desktop/Programming.nosync/datapipelines/video_metrics/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/oliverborchers/Desktop/Programming.nosync/datapipelines/video_metrics/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/oliverborchers/Desktop/Programming.nosync/datapipelines/video_metrics/node_modules/bluebird/js/release/async.js:102:5)
    at Async.drainQueues [as _onImmediate] (/Users/oliverborchers/Desktop/Programming.nosync/datapipelines/video_metrics/node_modules/bluebird/js/release/async.js:15:14)
    at process.processImmediate (node:internal/timers:475:21)

Environment information

Running "serverless" from node_modules
Framework Core: 3.27.0 (local) 3.30.1 (global)
Plugin: 6.2.3
SDK: 4.3.2
kallelat commented 1 year ago

I'm experiencing the exact same error - the only difference is using 3.31.0 version of the framework and node18.

kallelat commented 1 year ago

Just noticed, that with individually flag set to true the deploy works fine, ping @oborchers

package: individually: true