serverless/serverless

Expose actual error from spawned process

Opened this issue · 2 comments

Are you certain it's a bug?

  • Yes, it looks like a bug

Is the issue caused by a plugin?

  • It is not a plugin issue

Are you using the latest v3 release?

  • Yes, I'm using the latest v3 release

Is there an existing issue for this?

  • I have searched existing issues, it hasn't been reported yet

Issue description

We're using serverless invoke local --docker to test AWS Lambda layers before publishing.
While the actual issue related to the docker image has already been raised in dherault/serverless-offline#1750 and #12345 (and open PR in dherault/serverless-offline#1755), I'd like to suggest exposing the actual error since it's quite obscure and takes some time to figure out the actual issue.

Tests:
/home/circleci/project/tests/sample_handler.py
Environment: linux, node 16.16.0, framework 3.38.0 (standalone), plugin 7.2.0, SDK 4.5.1
Credentials: Local, environment variables
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
Error: `docker pull --disable-content-trust=false lambci/lambda:python3.8` Exited with code 1
    at ChildProcess.<anonymous> (/snapshot/serverless/node_modules/child-process-ext/spawn.js:38:8)
    at ChildProcess.emit (node:events:527:28)
    at ChildProcess.emit (node:domain:475:12)
    at maybeClose (node:internal/child_process:1092:16)
    at Socket.<anonymous> (node:internal/child_process:451:11)
    at Socket.emit (node:events:527:28)
    at Socket.emit (node:domain:475:12)
    at Pipe.<anonymous> (node:net:709:12)

1 deprecation found: run 'serverless doctor' for more details

Exited with code exit status 1

The expected error should include the actual error, e.g.:

ERRO[0000] Metadata for targets expired                 
ERRO[0000] Metadata for targets expired                 
Error: remote repository docker.io/lambci/lambda out-of-date: targets expired at Mon Jan 29 16:32:58 -0500 2024

Exited with code exit status 1

Service configuration (serverless.yml) content

service: my-service

provider:
  name: aws
  runtime: python3.8
  stage: dev
  region: us-east-1
  environment:
    PYTHONPATH: python:/opt/python

package:
  include:
    - python/**

functions:
  sample-function:
    handler: sample_handler.handler
    name: sample-function

Command name and used flags

serverless invoke local --function sample-function --docker

Command output

Tests:
/home/circleci/project/tests/sample_function.py
Environment: linux, node 16.16.0, framework 3.38.0 (standalone), plugin 7.2.0, SDK 4.5.1
Credentials: Local, environment variables
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
Error: `docker pull --disable-content-trust=false lambci/lambda:python3.8` Exited with code 1
    at ChildProcess.<anonymous> (/snapshot/serverless/node_modules/child-process-ext/spawn.js:38:8)
    at ChildProcess.emit (node:events:527:28)
    at ChildProcess.emit (node:domain:475:12)
    at maybeClose (node:internal/child_process:1092:16)
    at Socket.<anonymous> (node:internal/child_process:451:11)
    at Socket.emit (node:events:527:28)
    at Socket.emit (node:domain:475:12)
    at Pipe.<anonymous> (node:net:709:12)

1 deprecation found: run 'serverless doctor' for more details

Exited with code exit status 1

Environment information

Environment: linux, node 16.16.0, framework 3.38.0 (standalone), plugin 7.2.0, SDK 4.5.1

temporary workaround until an update for v3/v4 of serverless happens...

docker pull mlupin/docker-lambda:${runtime}
docker image tag  mlupin/docker-lambda:${runtime} lambci/lambda:${runtime}