question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiline output from local invoke gets chopped short

See original GitHub issue

Description:

When locally invoking lambdas via local invoke, multi-line console logs are typically cut short, causing them to be illegible.

Steps to reproduce:

  1. start a cdk TS project
  2. write lambda that produces multi line console log
  3. cdk synth project
  4. sam local invoke that lambda
  5. note that the multiline console log does not get formatted correctly

Observed result:

2022-03-23 10:22:25,016 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2022-03-23 10:22:25,016 | Using config file: samconfig.toml, config environment: default
2022-03-23 10:22:25,016 | Expand command line arguments to:
2022-03-23 10:22:25,016 | --template_file=/home/dakotal/Projects/QSR/myq_cloud_wfm/cdk.out/assembly-wfm-new-dev-pipeline-NewWfmStage/wfmnewdevpipelineNewWfmStageNewWfmStackIngestionStack5AC9C424.nested.template.json --function_logical_id=athenaHandler --layer_cache_basedir=/home/dakotal/.aws-sam/layers-pkg --container_host=localhost --container_host_interface=127.0.0.1 
2022-03-23 10:22:25,017 | local invoke command is called
2022-03-23 10:22:25,017 | No Parameters detected in the template
2022-03-23 10:22:25,028 | CDK Path for resource athenaResultsBucket77A2A720 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaResultsBucket', 'Resource']
2022-03-23 10:22:25,028 | CDK Path for resource athenaQueryFormatterServiceRole164919FA is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaQueryFormatter', 'ServiceRole', 'Resource']
2022-03-23 10:22:25,028 | CDK Path for resource athenaQueryFormatterServiceRoleDefaultPolicyD8E81B80 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaQueryFormatter', 'ServiceRole', 'DefaultPolicy', 'Resource']
2022-03-23 10:22:25,028 | CDK Path for resource athenaQueryFormatterD86A8A4A is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaQueryFormatter', 'Resource']
2022-03-23 10:22:25,028 | CDK Path for resource athenaHandlerServiceRole0BAF02D3 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaHandler', 'ServiceRole', 'Resource']
2022-03-23 10:22:25,028 | CDK Path for resource athenaHandler2182D0CE is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaHandler', 'Resource']
2022-03-23 10:22:25,028 | CDK Path for resource queryPrepRule73163A06 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'queryPrepRule', 'Resource']
2022-03-23 10:22:25,028 | CDK Path for resource queryPrepRuleAllowEventRulewfmnewdevpipelineNewWfmStageNewWfmStackIngestionStackathenaQueryFormatterE29DC9D75AA7B6E4 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'queryPrepRule', 'AllowEventRulewfmnewdevpipelineNewWfmStageNewWfmStackIngestionStackathenaQueryFormatterE29DC9D7']
2022-03-23 10:22:25,028 | CDK Path for resource athenaResultsRule3F12FB94 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaResultsRule', 'Resource']
2022-03-23 10:22:25,028 | CDK Path for resource athenaResultsRuleAllowEventRulewfmnewdevpipelineNewWfmStageNewWfmStackIngestionStackathenaHandler2A490B6C160F8596 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaResultsRule', 'AllowEventRulewfmnewdevpipelineNewWfmStageNewWfmStackIngestionStackathenaHandler2A490B6C']
2022-03-23 10:22:25,028 | CDK Path for resource CDKMetadata is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'CDKMetadata', 'Default']
2022-03-23 10:22:25,029 | 11 stacks found in the template
2022-03-23 10:22:25,029 | No Parameters detected in the template
2022-03-23 10:22:25,038 | CDK Path for resource athenaResultsBucket77A2A720 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaResultsBucket', 'Resource']
2022-03-23 10:22:25,038 | CDK Path for resource athenaQueryFormatterServiceRole164919FA is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaQueryFormatter', 'ServiceRole', 'Resource']
2022-03-23 10:22:25,038 | CDK Path for resource athenaQueryFormatterServiceRoleDefaultPolicyD8E81B80 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaQueryFormatter', 'ServiceRole', 'DefaultPolicy', 'Resource']
2022-03-23 10:22:25,038 | CDK Path for resource athenaQueryFormatterD86A8A4A is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaQueryFormatter', 'Resource']
2022-03-23 10:22:25,038 | CDK Path for resource athenaHandlerServiceRole0BAF02D3 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaHandler', 'ServiceRole', 'Resource']
2022-03-23 10:22:25,038 | CDK Path for resource athenaHandler2182D0CE is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaHandler', 'Resource']
2022-03-23 10:22:25,038 | CDK Path for resource queryPrepRule73163A06 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'queryPrepRule', 'Resource']
2022-03-23 10:22:25,039 | CDK Path for resource queryPrepRuleAllowEventRulewfmnewdevpipelineNewWfmStageNewWfmStackIngestionStackathenaQueryFormatterE29DC9D75AA7B6E4 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'queryPrepRule', 'AllowEventRulewfmnewdevpipelineNewWfmStageNewWfmStackIngestionStackathenaQueryFormatterE29DC9D7']
2022-03-23 10:22:25,039 | CDK Path for resource athenaResultsRule3F12FB94 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaResultsRule', 'Resource']
2022-03-23 10:22:25,039 | CDK Path for resource athenaResultsRuleAllowEventRulewfmnewdevpipelineNewWfmStageNewWfmStackIngestionStackathenaHandler2A490B6C160F8596 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaResultsRule', 'AllowEventRulewfmnewdevpipelineNewWfmStageNewWfmStackIngestionStackathenaHandler2A490B6C']
2022-03-23 10:22:25,039 | CDK Path for resource CDKMetadata is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'CDKMetadata', 'Default']
2022-03-23 10:22:25,039 | 11 resources found in the stack 
2022-03-23 10:22:25,039 | No Parameters detected in the template
2022-03-23 10:22:25,049 | CDK Path for resource athenaResultsBucket77A2A720 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaResultsBucket', 'Resource']
2022-03-23 10:22:25,049 | CDK Path for resource athenaQueryFormatterServiceRole164919FA is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaQueryFormatter', 'ServiceRole', 'Resource']
2022-03-23 10:22:25,049 | CDK Path for resource athenaQueryFormatterServiceRoleDefaultPolicyD8E81B80 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaQueryFormatter', 'ServiceRole', 'DefaultPolicy', 'Resource']
2022-03-23 10:22:25,049 | CDK Path for resource athenaQueryFormatterD86A8A4A is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaQueryFormatter', 'Resource']
2022-03-23 10:22:25,049 | CDK Path for resource athenaHandlerServiceRole0BAF02D3 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaHandler', 'ServiceRole', 'Resource']
2022-03-23 10:22:25,049 | CDK Path for resource athenaHandler2182D0CE is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaHandler', 'Resource']
2022-03-23 10:22:25,049 | CDK Path for resource queryPrepRule73163A06 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'queryPrepRule', 'Resource']
2022-03-23 10:22:25,049 | CDK Path for resource queryPrepRuleAllowEventRulewfmnewdevpipelineNewWfmStageNewWfmStackIngestionStackathenaQueryFormatterE29DC9D75AA7B6E4 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'queryPrepRule', 'AllowEventRulewfmnewdevpipelineNewWfmStageNewWfmStackIngestionStackathenaQueryFormatterE29DC9D7']
2022-03-23 10:22:25,049 | CDK Path for resource athenaResultsRule3F12FB94 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaResultsRule', 'Resource']
2022-03-23 10:22:25,049 | CDK Path for resource athenaResultsRuleAllowEventRulewfmnewdevpipelineNewWfmStageNewWfmStackIngestionStackathenaHandler2A490B6C160F8596 is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'athenaResultsRule', 'AllowEventRulewfmnewdevpipelineNewWfmStageNewWfmStackIngestionStackathenaHandler2A490B6C']
2022-03-23 10:22:25,049 | CDK Path for resource CDKMetadata is ['wfm-new-dev-pipeline', 'NewWfmStage', 'NewWfmStack', 'IngestionStack', 'CDKMetadata', 'Default']
2022-03-23 10:22:25,050 | Found Lambda function with name='athenaQueryFormatterD86A8A4A' and CodeUri='../asset.691dfa7b1cfa94ee92558d71b6aaf9fa4d0a4edd3d969794613ede5642e4617f'
2022-03-23 10:22:25,050 | --base-dir is not presented, adjusting uri ../asset.691dfa7b1cfa94ee92558d71b6aaf9fa4d0a4edd3d969794613ede5642e4617f relative to /home/dakotal/Projects/QSR/myq_cloud_wfm/cdk.out/assembly-wfm-new-dev-pipeline-NewWfmStage/wfmnewdevpipelineNewWfmStageNewWfmStackIngestionStack5AC9C424.nested.template.json
2022-03-23 10:22:25,050 | Found Lambda function with name='athenaHandler2182D0CE' and CodeUri='../asset.6d3f8650e2d8a66838f02bd14b54620193fa426d86b7e502ce686bf295e340c8'
2022-03-23 10:22:25,050 | --base-dir is not presented, adjusting uri ../asset.6d3f8650e2d8a66838f02bd14b54620193fa426d86b7e502ce686bf295e340c8 relative to /home/dakotal/Projects/QSR/myq_cloud_wfm/cdk.out/assembly-wfm-new-dev-pipeline-NewWfmStage/wfmnewdevpipelineNewWfmStageNewWfmStackIngestionStack5AC9C424.nested.template.json
2022-03-23 10:22:25,054 | Found one Lambda function with name 'athenaHandler'
2022-03-23 10:22:25,054 | Invoking index.handler (nodejs12.x)
2022-03-23 10:22:25,054 | Environment variables overrides data is standard format
2022-03-23 10:22:25,054 | Loading AWS credentials from session with profile 'None'
2022-03-23 10:22:25,433 | Resolving code path. Cwd=/home/dakotal/Projects/QSR/myq_cloud_wfm/cdk.out/assembly-wfm-new-dev-pipeline-NewWfmStage, CodeUri=/home/dakotal/Projects/QSR/myq_cloud_wfm/cdk.out/asset.6d3f8650e2d8a66838f02bd14b54620193fa426d86b7e502ce686bf295e340c8
2022-03-23 10:22:25,433 | Resolved absolute path to code is /home/dakotal/Projects/QSR/myq_cloud_wfm/cdk.out/asset.6d3f8650e2d8a66838f02bd14b54620193fa426d86b7e502ce686bf295e340c8
2022-03-23 10:22:25,434 | Code /home/dakotal/Projects/QSR/myq_cloud_wfm/cdk.out/asset.6d3f8650e2d8a66838f02bd14b54620193fa426d86b7e502ce686bf295e340c8 is not a zip/jar file
2022-03-23 10:22:25,469 | Skip pulling image and use local one: public.ecr.aws/sam/emulation-nodejs12.x:rapid-1.37.0-x86_64.

2022-03-23 10:22:25,469 | Mounting /home/dakotal/Projects/QSR/myq_cloud_wfm/cdk.out/asset.6d3f8650e2d8a66838f02bd14b54620193fa426d86b7e502ce686bf295e340c8 as /var/task:ro,delegated inside runtime container
2022-03-23 10:22:25,925 | Starting a timer for 3 seconds for function 'athenaHandler'
START RequestId: 39bd28f2-fc15-4b61-9fec-ba0811d295f1 Version: $LATEST
} retryDelay: 26.615532480739734aJhXlB/cEruDEVLWI+ATUg57Lj8glEuZnfkZVrRag53NRyN9vwxOJYmV7KtTrCptA=',e specified bucket does not exist
END RequestId: 39bd28f2-fc15-4b61-9fec-ba0811d295f1
REPORT RequestId: 39bd28f2-fc15-4b61-9fec-ba0811d295f1	Init Duration: 0.12 ms	Duration: 499.84 ms	Billed Duration: 500 ms	Memory Size: 128 MB	Max Memory Used: 128 MB	
false2022-03-23 10:22:26,890 | Cleaning all decompressed code dirs
2022-03-23 10:22:26,891 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '7946e37e-d7b8-495b-acf8-909052d2b18c', 'installationId': '9ff40e4f-c23a-44de-a170-371601e7b95f', 'sessionId': 'e5f3bd27-9f63-4268-bd4c-3fb876a0391e', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.7.10', 'samcliVersion': '1.37.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam local invoke', 'metricSpecificAttributes': {'projectType': 'CDK'}, 'duration': 1874, 'exitReason': 'success', 'exitCode': 0}}]}
2022-03-23 10:22:27,303 | Telemetry response: 200
2022-03-23 10:22:27,304 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2022-03-23 10:22:27,305 | Sending Telemetry: {'metrics': [{'runtimeMetric': {'requestId': '3e527121-4a24-473c-b65f-1579e350c105', 'installationId': '9ff40e4f-c23a-44de-a170-371601e7b95f', 'sessionId': 'e5f3bd27-9f63-4268-bd4c-3fb876a0391e', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.7.10', 'samcliVersion': '1.37.0', 'runtimes': ['nodejs12.x']}}]}
2022-03-23 10:22:27,712 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)

Expected result:

lambda is invoked, and multiline console log is formatted correctly, i.e. all lines appear in terminal as intended. Note: the “specified bucket does not exist” line is expected, as i’m configuring environment variables. however the entire output of the console.error is being truncated which is the issue.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS:$ uname -a Linux xx 5.13.0-35-generic #40-Ubuntu SMP Mon Mar 7 08:03:10 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
  2. sam --version: SAM CLI, version 1.37.0
  3. AWS region: us-east-1
  4. CF template is a build artifact from CDK synth

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:4
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
hawflaucommented, Mar 31, 2022

I’ve reproduced the issue. Will bring this up with team and prioritize fixing it.

0reactions
jankammerathcommented, Oct 23, 2022

I’d like to add that this behaviour appeared somewhere around mid 2021. Previous SAM versions didn’t have this behaviour. It’s a problem for the following reason: when running or building Lambda locally and an exception occurs, you’re forced to always debug instead of getting the trace from the console.

Read more comments on GitHub >

github_iconTop Results From Across the Web

bash - Multi-line string with extra space (preserved indentation)
Works on my mac with ) on the same line. I think it's because what goes between $( and ) is gonna execute...
Read more >
How do I trim leading and trailing whitespace from each line of ...
If the string one is trying to trim is short and continuous/contiguous, one can simply pass it as a parameter to any bash...
Read more >
F# code formatting guidelines | Microsoft Learn
Multi-line interpolated expressions are discouraged. Instead, bind the expression result to a value and use that in the interpolated string.
Read more >
Built-ins for strings - Apache FreeMarker Manual
If the string ends with multiple line-breaks, only the last line-break is removed. ... If the string doesn't start with the substring specified...
Read more >
Groovy Language Documentation
Here, we have a string with a placeholder referencing a local variable: ... Groovy's GPath notation allows a short-cut when the referenced property...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found