Write Only property fails to assert on nested properties
See original GitHub issueIn case of nested write only properties: https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-elasticloadbalancingv2/blob/master/aws-elasticloadbalancingv2-listener.json#L325
The contract test fails to assert: https://github.com/aws-cloudformation/cloudformation-cli/blob/master/src/rpdk/core/contract/suite/handler_commons.py#L15
The test fails with the following stack trace:
resource_model = {'AlpnPolicy': [], 'Certificates': [], 'DefaultActions': [{'ForwardConfig': {'TargetGroups': [{'TargetGroupArn': 'arn:...'arn:aws:elasticloadbalancing:us-east-1:362761549384:listener/net/MCM-29093805/37e4ea061f7d3f55/ee53b3bd90797dba', ...}
write_only_property = ('properties', 'DefaultActions', 'AuthenticateOidcConfig', 'ClientSecret')
@staticmethod
def key_error_safe_traverse(resource_model, write_only_property):
try:
return traverse(
> resource_model, fragment_list(write_only_property, "properties")
)[0]
../cloudformation-cli/cloudformation-cli/src/rpdk/core/contract/resource_client.py:235:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
document = [{'ForwardConfig': {'TargetGroups': [{'TargetGroupArn': 'arn:aws:elasticloadbalancing:us-east-1:362761549384:targetgro...tGroupArn': 'arn:aws:elasticloadbalancing:us-east-1:362761549384:targetgroup/CFN/c78de428819d902c', 'Type': 'forward'}]
path_parts = ['DefaultActions', 'AuthenticateOidcConfig', 'ClientSecret']
def traverse(document, path_parts):
"""Traverse the document according to the reference.
Since the document is presumed to be the reference's base, the base is
discarded. There is no validation that the reference is valid.
:raises ValueError, LookupError: the reference is invalid for this document
>>> traverse({"foo": {"bar": [42]}}, tuple())
({'foo': {'bar': [42]}}, (), None)
>>> traverse({"foo": {"bar": [42]}}, ["foo"])
({'bar': [42]}, ('foo',), {'foo': {'bar': [42]}})
>>> traverse({"foo": {"bar": [42]}}, ("foo", "bar"))
([42], ('foo', 'bar'), {'bar': [42]})
>>> traverse({"foo": {"bar": [42]}}, ("foo", "bar", "0"))
(42, ('foo', 'bar', 0), [42])
>>> traverse({}, ["foo"])
Traceback (most recent call last):
...
KeyError: 'foo'
>>> traverse([], ["foo"])
Traceback (most recent call last):
...
ValueError: invalid literal for int() with base 10: 'foo'
>>> traverse([], [0])
Traceback (most recent call last):
...
IndexError: list index out of range
"""
parent = None
path = []
for part in path_parts:
if isinstance(document, Sequence):
> part = int(part)
E ValueError: invalid literal for int() with base 10: 'AuthenticateOidcConfig'
../cloudformation-cli/cloudformation-cli/src/rpdk/core/jsonutils/utils.py:99: ValueError
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Jest: expect object not to have property - Stack Overflow
I want to assert that the property does not exist at all. Not just that it would be undefined when try to access....
Read more >How to write assertions in Postman (objects, arrays ... - YouTube
How to write assertions in Postman ( objects, arrays, nested properties ) ... Just fill out the form below: https://forms.gle/uWEzXFQ2viJtZtvZ7 ...
Read more >Object.defineProperty() - JavaScript - MDN Web Docs
A function which serves as a getter for the property, or undefined if there is no getter. When the property is accessed, this...
Read more >API Reference - Chai Assertion Library
Asserts that object has a direct or inherited property named by property , which can be a string using dot- and bracket-notation for...
Read more >its | Cypress Documentation
Index, name of property or name of nested properties (with dot notation) to get. options (Object) ... Assert that a property does not...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello, I’m also seeing this error for readOnlyProperties when running contract test for contract_create_read_success for our resource when i did “/properties/Subscribers/*/Status”. When I switched to “/properties/Subscribers/0/Status” like jotompki@ suggested, the error went away. What about array that has more than 1 object?
Updated: Not onlythe contract_create_read_success failed but the followings are also failing with the same error FAILED handler_create.py::contract_create_delete - ValueError: invalid literal for int() with base 10: ‘’ ERROR handler_create.py::contract_create_duplicate - ValueError: invalid literal for int() with base 10: '’ ERROR handler_create.py::contract_create_read_success - ValueError: invalid literal for int() with base 10: ‘’ ERROR handler_create.py::contract_create_list_success - ValueError: invalid literal for int() with base 10: '’ ERROR handler_delete.py::contract_delete_read - ValueError: invalid literal for int() with base 10: ‘’ ERROR handler_delete.py::contract_delete_list - ValueError: invalid literal for int() with base 10: '’ ERROR handler_delete.py::contract_delete_update - ValueError: invalid literal for int() with base 10: ‘’ ERROR handler_delete.py::contract_delete_delete - ValueError: invalid literal for int() with base 10: '’ ERROR handler_delete.py::contract_delete_create - ValueError: invalid literal for int() with base 10: ‘’ ERROR handler_update.py::contract_update_read_success - ValueError: invalid literal for int() with base 10: '’ ERROR handler_update.py::contract_update_list_success - ValueError: invalid literal for int() with base 10: ‘*’
I’m still seeing this limitation with readOnly properties with cloudformation-cli v0.2.6 (and resource providers created with
cloudformation-cli-python-lib==2.1.5
). The resource handlers work as expected, but contract tests fail due to the output model having additional readonly properties for list members.