cloudtools / troposphere

troposphere - Python library to create AWS CloudFormation descriptions
BSD 2-Clause "Simplified" License
4.93k stars 1.45k forks source link

Confusing/missleading error messages around required attributes for some types (resource_type not defined) #2020

Closed canopus1io closed 2 years ago

canopus1io commented 2 years ago
class CustomHeader(AWSProperty):
    """
    `CustomHeader <http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-responseheaderspolicy-customheader.html>`__
    """

    props: PropsDictType = {
        "Header": (str, True),
        "Override": (boolean, True),
        "Value": (str, True),
    }

troposphere.cloudfront.CustomHeader(Header="Cache-Policy", Value="no-cache")

Yields this error in validation: ValueError("Resource Override required in type <unknown type>")

A couple things wrong with this:

My proposal:

instead of falling back to we should fall back to the classname.

e.g. error would be this instead: ValueError("Resource Override required in type <class 'troposphere.cloudfront.CustomHeader'>")

My one liner PR for the change: https://github.com/cloudtools/troposphere/pull/2019

markpeek commented 2 years ago

Fixed via #2019 and merged via cf527ab34cc7fe147a039b26c65febd775d0d6ff