Skip to content

Fix: Corrected Validation Logic and Exception Handling for validate.py and SamTemplateValidator #7983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

Pranaykarvi
Copy link

Description:

This pull request addresses and fixes a validation bug in the SamTemplateValidator and the associated CLI command used to validate AWS SAM templates. The following changes have been made:

  • Updated the SamTemplateValidator to handle local CodeUri and ImageUri properly by replacing them with fake S3 URIs for SAM translation.
  • Fixed an issue in the validate.py file where the region or credentials weren’t being handled correctly during SAM template validation.
  • Modified the cli.py command to ensure the validation process is smooth and error-free when interacting with AWS services.

Changes:

  • SamTemplateValidator: Replaced local CodeUri and ImageUri with S3 URIs for correct SAM translation.
  • validate.py: Fixed region and credentials handling issues.
  • cli.py: Updated the command to handle validation better and give clear error messages.

How to test:

  1. Run the sam validate command with a sample SAM template to ensure that it correctly validates and processes local CodeUri and ImageUri.
  2. Test with both valid and invalid templates to check if proper error messages are displayed.
  3. Run the lint command to ensure that SAM template linting works as expected.

Related Issues:

  • Bugfix for invalid region and credential handling during SAM template validation.

Notes:

  • Ensure that you have your AWS credentials configured before testing the validation.
  • If you encounter any issues, refer to the error messages to resolve credential or region-related problems.

fixes #7973

@Pranaykarvi Pranaykarvi requested a review from a team as a code owner April 14, 2025 06:06
@github-actions github-actions bot added area/validate sam validate command pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Apr 14, 2025
@valerena
Copy link
Contributor

Hi. Thanks for the contribution! It looks like you missed to commit the changes from cli.py, alongside other of the changes you describe. The only changes visible right now are just comments/format, and handling of None returned by the transform. Please check the changes and make sure that you commited everything you meant to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/validate sam validate command pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: sam validate - TypeError
2 participants