Bug: `sam validate` fails to check for required metadata
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 1.2k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 52
Description
### Description:
A template with no `AWS::ServerlessRepo::Application` Metadata is not a valid template, and will not publish during `sam publish`, but `sam validate` will report that the template is valid.
### Steps to reproduce:
Remove or rename `AWS::ServerlessRepo::Application` in the template and run `sam validate` and `sam publish`.
### Observed result:
Success during `sam validate`, failure during `sam publish`.
```
/Users/jharker/Code/lambda-ebs-cleanup/template.yaml is a valid SAM Template
2022-09-06 11:31:07,926 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '44cdd239-0a95-478e-b395-48a700229648', 'installationId': '14965899-b0af-400e-8381-df4b766b7950', 'sessionId': '9e4ffd7f-47b2-42e7-a429-52a7b036acd7', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.13', 'samcliVersion': '1.53.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam validate', 'metricSpecificAttributes': {'projectType': 'CFN'}, 'duration': 3475, 'exitReason': 'success', 'exitCode': 0}}]}
2022-09-06 11:31:08,075 | Telemetry response: 200
```
```
Publish Failed
Error: Application metadata not found in the SAM template: 'missing AWS::ServerlessRepo::Application section in template Metadata'
Please follow the instructions in https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-template-publishing-applications.html
```
### Expected result:
An error message and a non-zero exit code during `sam validate`.
### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
1. OS: Mac
1. `sam --version`: 1.53.0
1. AWS region: us-east-1
Contributor guide
Assessment
This issue has not been assessed yet.