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

[Bug]: generate_params script type errors are not clear what's the issue #694

Open
2 tasks done
faridnsh opened this issue Mar 20, 2024 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@faridnsh
Copy link
Contributor

Is there an existing issue for this?

  • 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 = <generate_params.Parameters object at 0x10aca6710>

    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>
    lambda resolver: resolver.supports(lookup_str),
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <resolver_param_store.ResolverParamStore object at 0x10bcf7e50>
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(ef662ec)

Contributing a fix?

  • Yes, I am working on a fix to resolve this issue
@faridnsh faridnsh added the bug Something isn't working label Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant