aws / aws-sam-cli

CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM
https://aws.amazon.com/serverless/sam/
Apache License 2.0
6.5k stars 1.17k forks source link

Bug: An unexpected error was encountered while executing "sam build". #6113

Closed rajancstack closed 11 months ago

rajancstack commented 11 months ago

Description:

After deleting the build folder inside .aws-sam, sam build command doesn't work.

Steps to reproduce:

Delete the build folder inside .aws-sam

Observed result:

2023-10-19 14:39:23,285 | Config file location:
/Users/raj/Documents/development/CS-Internal-AWS/lambdas/cs-site-contact-us-notification/samconfig.toml
2023-10-19 14:39:23,287 | Loading configuration values from [default.['build'].parameters]
(env.command_name.section) in config file at
'/Users/raj/Documents/development/CS-Internal-AWS/lambdas/cs-site-contact-us-notification/samconfig.toml'. ..
2023-10-19 14:39:23,288 | Configuration values successfully loaded.
2023-10-19 14:39:23,288 | Configuration values are: {'stack_name': 'notifyuser', 'cached': True,
'parallel': True}
2023-10-19 14:39:23,293 | Using SAM Template at
/Users/raj/Documents/development/CS-Internal-AWS/lambdas/cs-site-contact-us-notification/template.yaml
2023-10-19 14:39:23,305 | Using config file: samconfig.toml, config environment: default
2023-10-19 14:39:23,305 | Expand command line arguments to:
2023-10-19 14:39:23,306 |
--template_file=/Users/raj/Documents/development/CS-Internal-AWS/lambdas/cs-site-contact-us-notification/t emplate.yaml --parallel --mount_with=READ --build_dir=.aws-sam/build --cache_dir=.aws-sam/cache --cached
2023-10-19 14:39:23,334 | 'build' command is called
2023-10-19 14:39:23,334 | Starting Build use cache
2023-10-19 14:39:23,338 | No Parameters detected in the template
2023-10-19 14:39:23,349 | Telemetry endpoint configured to be
https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2023-10-19 14:39:23,368 | Telemetry endpoint configured to be
https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2023-10-19 14:39:23,368 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId':
'4e0097a7-a9e6-49d9-ad89-656b55903ad8', 'installationId': '8a08de0c-be3a-4447-943c-2f8cba009101',
'sessionId': '744dbdbc-e05b-43d8-95e0-0bfa4c66f326', 'executionEnvironment': 'CLI', 'ci': False,
'pyversion': '3.8.13', 'samcliVersion': '1.97.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': None, 'projectName': '5658db932995a4daa28c7c9a04a243352cd3f942128022293ae133438449620e', 'initialCommit': None}, 'duration': 43, 'exitReason': 'InvalidSamDocumentException', 'exitCode': 255}}]}
2023-10-19 14:39:23,369 | Unable to find Click Context for getting session_id.
2023-10-19 14:39:23,371 | Sending Telemetry: {'metrics': [{'events': {'requestId':
'a033f208-4474-41fa-ae70-faf3b7e0f7cd', 'installationId': '8a08de0c-be3a-4447-943c-2f8cba009101',
'sessionId': '744dbdbc-e05b-43d8-95e0-0bfa4c66f326', 'executionEnvironment': 'CLI', 'ci': False,
'pyversion': '3.8.13', 'samcliVersion': '1.97.0', 'commandName': 'sam build', 'metricSpecificAttributes': {'events': [{'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id':
'6c76bbad61bc4a26a741f8cfdb2b5611', 'time_stamp': '2023-10-19 08:54:23.285', 'exception_name': None}]}}}]} 2023-10-19 14:39:24,453 |
HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed
out. (read timeout=0.1)
2023-10-19 14:39:24,455 |
HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed
out. (read timeout=0.1)

Expected result:

sam build should work without any exception

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

  1. OS: mac
  2. sam --version: version 1.97.0
  3. AWS region: us-east-2
# Paste the output of `sam --info` here

{ "version": "1.97.0", "system": { "python": "3.8.13", "os": "macOS-13.5.2-arm64-arm-64bit" }, "additional_dependencies": { "docker_engine": "Not available", "aws_cdk": "Not available", "terraform": "Not available" }, "available_beta_feature_env_vars": [ "SAM_CLI_BETA_FEATURES", "SAM_CLI_BETA_BUILD_PERFORMANCE", "SAM_CLI_BETA_TERRAFORM_SUPPORT", "SAM_CLI_BETA_RUST_CARGO_LAMBDA" ] } Add --debug flag to command you are running

mndeveci commented 11 months ago

Hi there,

We won't recommend changing the files/folders inside .aws-sam folder manually. SAM CLI uses that folder to keep its internal state.

Can you try to remove the entire .aws-sam folder and retry again?

github-actions[bot] commented 11 months ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.