aws / aws/aws-sam-cli

Bug: sam sync - [Errno 2] No such file or directory

Open
#5,939 2 comments 0 reactions 0 assignees View on GitHub
area/sync stage/needs-investigation
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

### Description:

After running sam sync and waiting for all of the infra to be deployed, i get the following error:

```
Error: [Errno 2] No such file or directory
```

The source of the error appears to be the StateMachine inside of the nested stack.

This StateMachine references a .json file that is in a parent directory. After seeing the following message in the debug logs, i tried moving the json file to the same folder as the template.yml of the nested stack, but the error stays the same.

```
2023-09-15 13:54:10,148 | File /home/delano/Documents/temp/sam-project/../../../statemachine/cria_oferta.asl.json failed to validate due to file path does not exist. Please verify that the path is valid.
```

I also tried disabling the telemetry by setting SAM_CLI_TELEMETRY=0, but the error persisted.

Please let me know if there's any more information that i can provide.

---

Tree:
```
├── README.md
├── samconfig.toml
├── src
│   └── apps
│   └── cria-oferta-service
│   └── template.yaml
├── statemachine
│   └── cria_oferta.asl.json
└── template.yaml
```

---

template.yaml (root)

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Vacation Tracker API

Globals:
Function:
Runtime: nodejs16.x
Tracing: Active

Resources:
CriaOfertaService:
Type: AWS::Serverless::Application
Properties:
Location: src/apps/cria-oferta-service/template.yaml

```

src/apps/cria-oferta-service/template.yaml

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Cria Oferta Service

Globals:
Function:
Tracing: Active
Runtime: nodejs16.x
Timeout: 120
Architectures:
- x86_64

Resources:
CriaOfertaStateMachineRole:
Type: AWS::IAM::Role
Properties:
RoleName: CriaOfertaStateMachineRole
Path: !Join ['', ['/', !Ref 'AWS::StackName', '/']]
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/AWSStepFunctionsFullAccess'
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: 'AllowStepFunctionsServiceToAssumeRole2'
Effect: 'Allow'
Action:
- 'sts:AssumeRole'
Principal:
Service:
- !Sub 'states.${AWS::Region}.amazonaws.com'

CriaOfertaStateMachine:
Type: AWS::Serverless::StateMachine
Properties:
Name: CriaOfertaStateMachine
Type: STANDARD
Role: !GetAtt CriaOfertaStateMachineRole.Arn
DefinitionUri: ../../../statemachine/cria_oferta.asl.json
```

### Steps to reproduce:

sam sync -u

### Observed result:

sam sync -u --debug
```
...
2023-09-15 13:54:08,188 |
Stack creation succeeded. Sync infra completed.

2023-09-15 13:54:08,190 | {'StackId': 'arn:aws:cloudformation:us-east-1:865522842129:stack/bialog-aws-sam-poc/63fbd2b0-53e8-11ee-99ce-0ae05b70bdc3', 'ResponseMetadata': {'RequestId':
'f5256364-e008-44b9-97c0-9decc496d75d', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': 'f5256364-e008-44b9-97c0-9decc496d75d', 'date': 'Fri, 15 Sep 2023 16:53:27 GMT',
'content-type': 'text/xml', 'content-length': '388', 'connection': 'keep-alive'}, 'RetryAttempts': 0}}
2023-09-15 13:54:08,192 | Updating latest_infra_sync_time in sync state
2023-09-15 13:54:08,196 | No Parameters detected in the template
2023-09-15 13:54:08,197 | There is no customer defined id or cdk path defined for resource CriaOfertaService, so we will use the resource logical id as the resource id
2023-09-15 13:54:08,202 | 1 stacks found in the template
2023-09-15 13:54:08,207 | No Parameters detected in the template
2023-09-15 13:54:08,208 | There is no customer defined id or cdk path defined for resource CriaOfertaStateMachineRole, so we will use the resource logical id as the resource id
2023-09-15 13:54:08,209 | There is no customer defined id or cdk path defined for resource CriaOfertaStateMachine, so we will use the resource logical id as the resource id
2023-09-15 13:54:08,211 | 0 stacks found in the template
2023-09-15 13:54:08,211 | Loading physical ID mapping
2023-09-15 13:54:08,248 | Fetching stack (bialog-aws-sam-poc) resources
2023-09-15 13:54:09,177 | Fetching stack (arn:aws:cloudformation:us-east-1:865522842129:stack/bialog-aws-sam-poc-CriaOfertaService-AWOO87CG8O0Y/67531400-53e8-11ee-9a68-0e2a0bfcc015)
resources
2023-09-15 13:54:10,030 | No Parameters detected in the template
2023-09-15 13:54:10,032 | There is no customer defined id or cdk path defined for resource CriaOfertaService, so we will use the resource logical id as the resource id
2023-09-15 13:54:10,040 | 1 stacks found in the template
2023-09-15 13:54:10,048 | No Parameters detected in the template
2023-09-15 13:54:10,049 | There is no customer defined id or cdk path defined for resource CriaOfertaStateMachineRole, so we will use the resource logical id as the resource id
2023-09-15 13:54:10,051 | There is no customer defined id or cdk path defined for resource CriaOfertaStateMachine, so we will use the resource logical id as the resource id
2023-09-15 13:54:10,053 | 0 stacks found in the template
2023-09-15 13:54:10,067 | No Parameters detected in the template
2023-09-15 13:54:10,095 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CriaOfertaService is CriaOfertaService
2023-09-15 13:54:10,096 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CriaOfertaService is CriaOfertaService
2023-09-15 13:54:10,097 | No Parameters detected in the template
2023-09-15 13:54:10,124 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CriaOfertaStateMachineRole is CriaOfertaStateMachineRole
2023-09-15 13:54:10,126 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CriaOfertaStateMachine is CriaOfertaStateMachine
2023-09-15 13:54:10,129 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CriaOfertaStateMachineRole is CriaOfertaStateMachineRole
2023-09-15 13:54:10,130 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CriaOfertaStateMachine is CriaOfertaStateMachine
2023-09-15 13:54:10,132 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CriaOfertaService is CriaOfertaService
2023-09-15 13:54:10,134 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CriaOfertaService is CriaOfertaService
2023-09-15 13:54:10,135 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CriaOfertaService is CriaOfertaService
2023-09-15 13:54:10,136 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CriaOfertaStateMachineRole is CriaOfertaStateMachineRole
2023-09-15 13:54:10,137 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CriaOfertaStateMachineRole is CriaOfertaStateMachineRole
2023-09-15 13:54:10,139 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CriaOfertaStateMachineRole is CriaOfertaStateMachineRole
2023-09-15 13:54:10,140 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CriaOfertaStateMachineRole is CriaOfertaStateMachineRole
2023-09-15 13:54:10,141 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CriaOfertaStateMachine is CriaOfertaStateMachine
2023-09-15 13:54:10,142 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CriaOfertaStateMachineRole is CriaOfertaStateMachineRole
2023-09-15 13:54:10,143 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CriaOfertaStateMachine is CriaOfertaStateMachine
2023-09-15 13:54:10,144 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CriaOfertaStateMachineRole is CriaOfertaStateMachineRole
2023-09-15 13:54:10,145 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CriaOfertaStateMachine is CriaOfertaStateMachine
2023-09-15 13:54:10,146 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CriaOfertaStateMachineRole is CriaOfertaStateMachineRole
2023-09-15 13:54:10,147 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CriaOfertaStateMachine is CriaOfertaStateMachine
2023-09-15 13:54:10,148 | File /home/delano/Documents/temp/sam-project/../../../statemachine/cria_oferta.asl.json failed to validate due to file path does not exist. Please verify that the
path is valid.
2023-09-15 13:54:10,150 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2023-09-15 13:54:10,151 | Unable to find Click Context for getting session_id.
2023-09-15 13:54:10,153 | Sending Telemetry: {'metrics': [{'events': {'requestId': '02afbc28-c273-4ff3-8d03-3d61aa503ce1', 'installationId': '832d15bf-292a-4b66-ad2c-4adc9642f133',
'sessionId': 'dceae456-2bc6-4311-b0b7-b960b9284f05', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.11.3', 'samcliVersion': '1.94.0', 'metricSpecificAttributes': {'events':
[{'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': 'a5fa6d8155fc4055a75fa7e71926e307', 'time_stamp': '2023-09-15 16:53:19.392', 'exception_name': None},
{'event_name': 'SyncUsed', 'event_value': 'Start', 'thread_id': 'acbc9567dab3474db027672d51815345', 'time_stamp': '2023-09-15 16:53:19.436', 'exception_name': None}, {'event_name':
'UsedFeature', 'event_value': 'Accelerate', 'thread_id': '0d7c2d3377e34b7185bbea78734afda1', 'time_stamp': '2023-09-15 16:53:22.317', 'exception_name': None}, {'event_name':
'SyncFlowStart', 'event_value': 'SkipInfraSyncExecute', 'thread_id': 'da7f6b7f55674ac2855e34b0bdc563b6', 'time_stamp': '2023-09-15 16:53:24.050', 'exception_name': None}, {'event_name':
'SyncFlowStart', 'event_value': 'InfraSyncExecute', 'thread_id': 'da7f6b7f55674ac2855e34b0bdc563b6', 'time_stamp': '2023-09-15 16:53:24.709', 'exception_name': None}, {'event_name':
'SyncFlowEnd', 'event_value': 'InfraSyncExecute', 'thread_id': 'da7f6b7f55674ac2855e34b0bdc563b6', 'time_stamp': '2023-09-15 16:54:08.192', 'exception_name': None}, {'event_name':
'SyncUsed', 'event_value': 'End', 'thread_id': 'acbc9567dab3474db027672d51815345', 'time_stamp': '2023-09-15 16:54:10.150', 'exception_name': None}]}}}]}
2023-09-15 13:54:10,159 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2023-09-15 13:54:10,183 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '53405efb-7d3f-497c-b215-b74f14c84c6e', 'installationId': '832d15bf-292a-4b66-ad2c-4adc9642f133',
'sessionId': 'dceae456-2bc6-4311-b0b7-b960b9284f05', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.11.3', 'samcliVersion': '1.94.0', 'awsProfileProvided': False,
'debugFlagProvided': True, 'region': '', 'commandName': 'sam sync', 'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': None, 'projectName':
'ba12dd46df5d1c2caa325be326f7a6bf6c346021ae0cf771a329ffeca59d5819', 'initialCommit': None}, 'duration': 50723, 'exitReason': 'FileNotFoundError', 'exitCode': 255}}]}
2023-09-15 13:54:10,988 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
2023-09-15 13:54:10,991 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)

Error: [Errno 2] No such file or directory
Traceback:
File "click/core.py", line 1055, in main
File "click/core.py", line 1657, in invoke
File "click/core.py", line 1404, in invoke
File "click/core.py", line 760, in invoke
File "click/decorators.py", line 84, in new_func
File "click/core.py", line 760, in invoke
File "samcli/lib/telemetry/metric.py", line 184, in wrapped
File "samcli/lib/telemetry/metric.py", line 149, in wrapped
File "samcli/lib/telemetry/event.py", line 353, in wrapped
File "samcli/lib/telemetry/event.py", line 345, in wrapped
File "samcli/lib/cli_validation/image_repository_validation.py", line 110, in wrapped
File "samcli/lib/telemetry/metric.py", line 103, in wrapped
File "samcli/lib/utils/version_checker.py", line 42, in wrapped
File "samcli/cli/main.py", line 95, in wrapper
File "samcli/commands/_utils/cdk_support_decorators.py", line 39, in wrapped
File "samcli/commands/_utils/command_exception_handler.py", line 88, in wrapper_command_exception_handler
File "samcli/commands/_utils/command_exception_handler.py", line 68, in wrapper_command_exception_handler
File "samcli/commands/sync/command.py", line 217, in cli
File "samcli/commands/sync/command.py", line 391, in do_cli
File "samcli/commands/sync/command.py", line 549, in execute_watch
File "samcli/lib/sync/watch_manager.py", line 209, in start
File "samcli/lib/sync/watch_manager.py", line 224, in _start
File "samcli/lib/sync/watch_manager.py", line 264, in _execute_infra_sync
File "samcli/lib/sync/watch_manager.py", line 233, in _start_sync
File "samcli/lib/sync/watch_manager.py", line 147, in _add_code_triggers
File "samcli/lib/utils/path_observer.py", line 138, in schedule_handlers
File "samcli/lib/utils/path_observer.py", line 155, in schedule_handler
File "watchdog/observers/api.py", line 297, in schedule
File "watchdog/utils/__init__.py", line 93, in start
File "watchdog/observers/inotify.py", line 118, in on_thread_start
File "watchdog/observers/inotify_buffer.py", line 35, in __init__
File "watchdog/observers/inotify_c.py", line 169, in __init__
File "watchdog/observers/inotify_c.py", line 385, in _add_watch
File "watchdog/observers/inotify_c.py", line 405, in _raise_error

An unexpected error was encountered while executing "sam sync".

```
`sam --info`

```
{
"version": "1.94.0",
"system": {
"python": "3.11.3",
"os": "Linux-6.1.46-1-lts-x86_64-with-glibc2.38"
},
"additional_dependencies": {
"docker_engine": "24.0.5",
"aws_cdk": "Not available",
"terraform": "1.5.5"
},
"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"
]
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.