Open abelperezok opened 4 years ago
Don't know if this is related, but when you execute sam local start-lambda
all the container output is also sent to stderr.
This makes it difficult to differentiate between real error output and standard logs when using the local lambda endpoint to test the lambda functions.
@abelperezok Thanks for raising this! would you consider a general rule that all workflows would need to get all their output over to stdout?
@sriram-mv Yes, I'd consider a general rule to get all workloads output to stdout, I'm not sure how complex it is internally but ideally only errors should go to stderr as it can confuse the caller process about the invocation outcome.
Hi @abelperezok ,
When I checked for dotnet workflow, I saw that we are piping the output of the dotnet CLI that we run for the build. https://github.com/aws/aws-lambda-builders/blob/8d817fd769133f18d028c0e911372938475fb65b/aws_lambda_builders/workflows/dotnet_clipackage/dotnetcli.py#L57
Since we are just piping whatever output comes from the underlying CLI that we run, could this be coming from dotnet CLI?
Description
When running sam build on a dotnet core lambda project, most of the output is sent to STDERR as opposed to STDOUT. This can be particularly confusing when running this command as part of a CI pipeline such as Azure DevOps as it can fail the step for no good reason.
Steps to reproduce
Run sam build and at glance all the output seems ok, but it's sending a big chunk of output to STDERR.
Observed result
Following a trick found in another thread azure-pipelines-tasks/issues/6840 I can see that most of the output is actually sent to STDERR.
The trick is to add
2> >(while read line; do (>&2 echo "STDERROR: $line"); done)
at the end of the command and it will prepend "STDERROR: " to each line sent to STDERR.Another simpler way to test it is to get rid of the error log by redirecting to null:
Only a few lines are displayed as normal standard output.
Expected result
No output sent to STDERR unless it's actually an error with the command.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: