serverless-python-requirements: Fatal error when trying to deploy single-functions

FYI: This is with the latest code from master Version: serverless@1.26.1 Steps to reproduce: Create any/simple stack which uses this plugin, and try to do a single-function deploy.

  Error --------------------------------------------------
 
  Unsupported type: data is neither a path or a Buffer
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Stack Trace --------------------------------------------
 
Error: Unsupported type: data is neither a path or a Buffer
    at Object.ZipLocal.sync.unzip (/Users/farley/myService/node_modules/zip-local/main.js:386:15)
    at injectRequirements (/Users/farley/myService/node_modules/serverless-python-requirements/lib/inject.js:45:27)
    at ServerlessPythonRequirements.injectAllRequirements (/Users/farley/myService/node_modules/serverless-python-requirements/lib/inject.js:118:5)
From previous event:
    at PluginManager.invoke (/Users/farley/.npm-packages/lib/node_modules/serverless/lib/classes/PluginManager.js:372:22)
    at PluginManager.run (/Users/farley/.npm-packages/lib/node_modules/serverless/lib/classes/PluginManager.js:403:17)
    at variables.populateService.then (/Users/farley/.npm-packages/lib/node_modules/serverless/lib/Serverless.js:102:33)
    at runCallback (timers.js:672:20)
    at tryOnImmediate (timers.js:645:5)
    at processImmediate [as _immediateCallback] (timers.js:617:5)
From previous event:
    at Serverless.run (/Users/farley/.npm-packages/lib/node_modules/serverless/lib/Serverless.js:89:74)
    at serverless.init.then (/Users/farley/.npm-packages/lib/node_modules/serverless/bin/serverless:42:50)
# serverless.yml
service: myService

provider:
  name: aws
  runtime: python2.7

plugins:
  - serverless-python-requirements

custom: 
  pythonRequirements:
    dockerizePip: true

functions:
  hello:
    handler: handler.hello
# requirements.txt
requests

master/bleeding edge might not be ready yet, I was just developing something on top of it and ran into this.

Cheers!

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 6
  • Comments: 16

Commits related to this issue

Most upvoted comments

@dschep While both seem to trigger the same “after” handler from plugin-hooks, it looks like when running sls package the value this.serverless.service.package.artifact is correctly pointing to the “big zip file”. In contrast, when running sls deploy -f funcname the artifact is undefined.

I suspect what’s happening is that a non-null artifact value is a side-effect of the packaging step, which is skipped when doing partial deploys. Specifically this part of the core serverless app:

packageAll() {
  const zipFileName = `${this.serverless.service.service}.zip`;

  return this.resolveFilePathsAll().then(filePaths =>
    this.zipFiles(filePaths, zipFileName).then(filePath => {
      // only set the default artifact for backward-compatibility
      // when no explicit artifact is defined
      if (!this.serverless.service.package.artifact) {
        this.serverless.service.package.artifact = filePath;
        this.serverless.service.artifact = filePath;
      }
      return filePath;
    })
  );
},