cfn test > InvalidRequest
wnkz opened this issue · 4 comments
Command cfn test
from cloudformation-cli generates exception in plugin / lib.
cloudformation_cli_python_lib.exceptions.InvalidRequest: __init__() missing 1 required positional argument: 'responseEndpoint' (TypeError)
Using versions:
- cloudformation-cli==0.1.10
- cloudformation-cli-python-plugin==2.1.1
- cloudformation-cli-python-lib==2.1.1
This is following the release of new versions and the close of issue #112.
Steps to reproduce
Init project
> pipenv --python 3.7.7 install cloudformation-cli cloudformation-cli-python-plugin
> mkdir foo-bar-baz
> cd foo-bar-baz
> pipenv run cfn init
Initializing new project
What's the name of your resource type?
(Organization::Service::Resource)
>> Foo::Bar::Baz
Select a language for code generation:
[1] python36
[2] python37
(enter an integer):
>> 2
Use docker for platform-independent packaging (Y/n)?
This is highly recommended unless you are experienced
with cross-platform Python packaging.
>> Y
Initialized a new project in /private/var/folders/bf/f_z6y6n959193x3csh_pcb0m0000gn/T/tmp.Zk4oqzlM/foo-bar-baz
Build
> pipenv run cfn generate
Generated files for Foo::Bar::Baz
> pipenv run cfn submit --dry-run
Starting Docker build. This may take several minutes if the image 'lambci/lambda:build-python3.7' needs to be pulled first.
Dry run complete: /private/var/folders/bf/f_z6y6n959193x3csh_pcb0m0000gn/T/tmp.Zk4oqzlM/foo-bar-baz/foo-bar-baz.zip
Test
On two separate shells run
sam local start-lambda
pipenv run cfn test
Lambda output (sam)
START RequestId: b5370d6b-fc74-190a-1bbc-79286a89ddab Version: $LATEST
[ERROR] 2020-09-15T14:23:24.348Z b5370d6b-fc74-190a-1bbc-79286a89ddab Invalid request
Traceback (most recent call last):
File "/var/task/cloudformation_cli_python_lib/resource.py", line 142, in _parse_request
event = HandlerRequest.deserialize(event_data)
File "/var/task/cloudformation_cli_python_lib/utils.py", line 98, in deserialize
event = HandlerRequest(**json_data)
TypeError: __init__() missing 1 required positional argument: 'responseEndpoint'
Handler error
Traceback (most recent call last):
File "/var/task/cloudformation_cli_python_lib/resource.py", line 142, in _parse_request
event = HandlerRequest.deserialize(event_data)
File "/var/task/cloudformation_cli_python_lib/utils.py", line 98, in deserialize
event = HandlerRequest(**json_data)
TypeError: __init__() missing 1 required positional argument: 'responseEndpoint'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/var/task/cloudformation_cli_python_lib/resource.py", line 187, in __call__
sessions, action, callback, event = self._parse_request(event_data)
File "/var/task/cloudformation_cli_python_lib/resource.py", line 150, in _parse_request
raise InvalidRequest(f"{e} ({type(e).__name__})") from e
cloudformation_cli_python_lib.exceptions.InvalidRequest: __init__() missing 1 required positional argument: 'responseEndpoint' (TypeError)
END RequestId: b5370d6b-fc74-190a-1bbc-79286a89ddab
REPORT RequestId: b5370d6b-fc74-190a-1bbc-79286a89ddab Init Duration: 480.13 ms Duration: 7.30 ms Billed Duration: 100 ms Memory Size: 256 MB Max Memory Used: 32 MB
Ah the field should be optional. Addressed the issue in #123 and will test further in the motion. I initially removed the responseEndpoint fully when testing but added it back in as it is required by our backend. Apologies
Release with optional field: https://pypi.org/project/cloudformation-cli-python-lib/2.1.2/
Please update your requirements to 2.1.2 https://github.com/aws-cloudformation/cloudformation-cli-python-plugin/blob/master/python/rpdk/python/templates/requirements.txt#L1 and let me know if that fixes the issue.
We will update this template as well and release a new version of the plugin so that these one off updates to the config file aren't necessary every release.
Thanks, I'd need to do more testing with a "real" resource but yes, the problem with responseEndpoint
seems to be fixed using python-lib 2.1.2