awslabs / awslabs/aws-deployment-framework
[Bug]: generate_params script type errors are not clear what's the issue
- Dominant language
- Python
- Stars
- 699
- Forks
- 235
- Avg merge
- 20h 53m
- Merged PRs (30d)
- 7
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Describe the bug
If you run generate_params with a params file that contains a parameter that is not a string, you will get an error like `'int' object has no attribute 'startswith'`.
### Expected Behavior
It should instead provide an error message saying certain parameter in certain file should be a string.
### Current Behavior
Here's how the error currently looks(from a quick modification of current unit tests):
```
tests/test_generate_params.py:211 (test_merge_params)
cls =
def test_merge_params(cls):
shutil.copy(
f"{cls.cwd}/stub_cfn_global_invalid.json",
f"{cls.cwd}/params/global.json",
)
with patch.object(
ParameterStore,
'fetch_parameter',
return_value='something'
):
parse = cls._parse(
cls.cwd,
'global',
)
> compare = cls._merge_params(
parse,
{'Parameters': {}, 'Tags': {}}
)
test_generate_params.py:226:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../generate_params.py:446: in _merge_params
self.resolver.apply_intrinsic_function_if_any(
../resolver.py:59: in apply_intrinsic_function_if_any
matching_resolver = self._matching_intrinsic_resolver(lookup_value)
../resolver.py:32: in _matching_intrinsic_resolver
matches = list(filter(
../resolver.py:33: in
lambda resolver: resolver.supports(lookup_str),
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
lookup_str = 1
def supports(self, lookup_str: str) -> bool:
"""
Check if this resolver supports the lookup_str syntax.
Args:
lookup_str (str): The lookup string that might have resolve: or
another resolver syntax.
Returns:
bool: True if this resolver supports the lookup_str syntax.
In other words, the lookup_str starts with `resolve:`.
False if not.
"""
> return lookup_str.startswith('resolve:')
E AttributeError: 'int' object has no attribute 'startswith'
../resolver_param_store.py:89: AttributeError
```
### Steps To Reproduce
1. Run generate_params script with a params file that contains a parameter value that is not a string:
global.yml:
```
Parameters:
Budget: 100
```
### Possible Solution
We should run something similar to schema_validation for the parameter files before processing them. I'm happy to contribute to this, if the other contributers see no issues with or if there's a particular way that it should be done.
### Additional Information/Context
_No response_
### ADF Version
Latest master(ef662ece1227d62de105dda450c98f2d0d79b83e)
### Contributing a fix?
- [X] Yes, I am working on a fix to resolve this issue
Contributor guide
Research direction
Start with tests/test_generate_params.py::test_merge_params and the traceback paths in generate_params.py, resolver.py, and resolver_param_store.py. Reproduce the failure using the shown global.yml value, then verify that invalid non-string parameters produce an error identifying the parameter and file instead of an AttributeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100