Skip to content
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

Typo in Properties for Api in template is not handled with 4xx error #766

Closed
ylynn opened this issue Jan 15, 2019 · 2 comments
Closed

Typo in Properties for Api in template is not handled with 4xx error #766

ylynn opened this issue Jan 15, 2019 · 2 comments

Comments

@ylynn
Copy link
Contributor

ylynn commented Jan 15, 2019

Description:
Template with a typo in template is not handled as expected. Under Properties of an api event, use "methid" instead of "method". Get 5xx error.

Steps to reproduce the issue:

  1. Create an template with an Api event, under "Properties", use "methid" instead of "method"
  2. Publish to aws serverless application repository

Observed result:
Get a 5xx error

Expected result:
Should be handled as a 4xx with error message

@jlhood jlhood added contributors/good-first-issue Good first issue for a contributor and removed contributors/good-first-issue Good first issue for a contributor labels Jan 15, 2019
@jlhood
Copy link
Contributor

jlhood commented Jan 15, 2019

Was able to reproduce this issue. Transform error when Method isn't present due to misspelling:

Traceback (most recent call last):
  File "./sam-translate.py", line 65, in <module>
    main()
  File "./sam-translate.py", line 49, in main
    sam_template, {}, ManagedPolicyLoader(iam_client))
  File "/Users/keeton/workplace/GitHub/keetonian/serverless-application-model/samtranslator/translator/transform.py", line 16, in transform
    return translator.translate(input_fragment, parameter_values=parameter_values)
  File "/Users/keeton/workplace/GitHub/keetonian/serverless-application-model/samtranslator/translator/translator.py", line 55, in translate
    sam_plugins=sam_plugins
  File "/Users/keeton/workplace/GitHub/keetonian/serverless-application-model/samtranslator/parser/parser.py", line 12, in parse
    sam_plugins.act(LifeCycleEvents.before_transform_template, sam_template)
  File "/Users/keeton/workplace/GitHub/keetonian/serverless-application-model/samtranslator/plugins/__init__.py", line 136, in act
    raise ex
KeyError: 'Method'

The issue is that the implicit API plugin is assuming the Method property is there:

https://github.com/awslabs/serverless-application-model/blob/develop/samtranslator/plugins/api/implicit_api_plugin.py#L191

We need to patch implicit_api_plugin.py to be more defensive. Should use get() instead of assuming property keys are present.

@keetonian
Copy link
Contributor

Released with SAM v1.11.0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants