prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  String misinterpreted as an int results in error on E2015
  ```
  cfn-lint --version
  cfn-lint 0.19.1
  ```
  
  *Description of issue.*
  The following template
  ```
  Parameters:
    CentralAccountId:
      Default: 112233445566
      MaxLength: 12
      MinLength: 12
      Type: String
  ```
  result in the error:
  ```
  E0002 Unknown exception while processing rule E2015: object of type 'int' has no len()
  application-account-initial-setup.yaml:1:1
  ```
  
  It is solved by putting quotes on the default value. However it is valid to not putting the quotes.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/cfnlint/rules/parameters/Default.py`
  Content:
  ```
  1 """
  2   Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3 
  4   Permission is hereby granted, free of charge, to any person obtaining a copy of this
  5   software and associated documentation files (the "Software"), to deal in the Software
  6   without restriction, including without limitation the rights to use, copy, modify,
  7   merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
  8   permit persons to whom the Software is furnished to do so.
  9 
  10   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  11   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  12   PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  13   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  14   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  15   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  16 """
  17 import re
  18 import six
  19 from cfnlint import CloudFormationLintRule
  20 from cfnlint import RuleMatch
  21 
  22 
  23 class Default(CloudFormationLintRule):
  24     """Check if Parameters are configured correctly"""
  25     id = 'E2015'
  26     shortdesc = 'Default value is within parameter constraints'
  27     description = 'Making sure the parameters have a default value inside AllowedValues, MinValue, MaxValue, AllowedPattern'
  28     source_url = 'https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html'
  29     tags = ['parameters']
  30 
  31     def check_allowed_pattern(self, allowed_value, allowed_pattern, path):
  32         """
  33             Check allowed value against allowed pattern
  34         """
  35         message = 'Default should be allowed by AllowedPattern'
  36         try:
  37             if not re.match(allowed_pattern, str(allowed_value)):
  38                 return([RuleMatch(path, message)])
  39         except re.error as ex:
  40             self.logger.debug('Regex pattern "%s" isn\'t supported by Python: %s', allowed_pattern, ex)
  41 
  42         return []
  43 
  44     def check_min_value(self, allowed_value, min_value, path):
  45         """
  46             Check allowed value against min value
  47         """
  48         message = 'Default should be equal to or higher than MinValue'
  49 
  50         if isinstance(allowed_value, six.integer_types) and isinstance(min_value, six.integer_types):
  51             if allowed_value < min_value:
  52                 return([RuleMatch(path, message)])
  53 
  54         return []
  55 
  56     def check_max_value(self, allowed_value, max_value, path):
  57         """
  58             Check allowed value against max value
  59         """
  60         message = 'Default should be less than or equal to MaxValue'
  61 
  62         if isinstance(allowed_value, six.integer_types) and isinstance(max_value, six.integer_types):
  63             if allowed_value > max_value:
  64                 return([RuleMatch(path, message)])
  65 
  66         return []
  67 
  68     def check_allowed_values(self, allowed_value, allowed_values, path):
  69         """
  70             Check allowed value against allowed values
  71         """
  72         message = 'Default should be a value within AllowedValues'
  73 
  74         if allowed_value not in allowed_values:
  75             return([RuleMatch(path, message)])
  76 
  77         return []
  78 
  79     def check_min_length(self, allowed_value, min_length, path):
  80         """
  81             Check allowed value against MinLength
  82         """
  83         message = 'Default should have a length above or equal to MinLength'
  84 
  85         if isinstance(min_length, six.integer_types):
  86             if len(allowed_value) < min_length:
  87                 return([RuleMatch(path, message)])
  88 
  89         return []
  90 
  91     def check_max_length(self, allowed_value, max_length, path):
  92         """
  93             Check allowed value against MaxLength
  94         """
  95         message = 'Default should have a length below or equal to MaxLength'
  96 
  97         if isinstance(max_length, six.integer_types):
  98             if len(allowed_value) > max_length:
  99                 return([RuleMatch(path, message)])
  100 
  101         return []
  102 
  103     def match(self, cfn):
  104         """Check CloudFormation Parameters"""
  105 
  106         matches = []
  107 
  108         for paramname, paramvalue in cfn.get_parameters().items():
  109             default_value = paramvalue.get('Default')
  110             if default_value is not None:
  111                 path = ['Parameters', paramname, 'Default']
  112                 allowed_pattern = paramvalue.get('AllowedPattern')
  113                 if allowed_pattern:
  114                     matches.extend(
  115                         self.check_allowed_pattern(
  116                             default_value, allowed_pattern, path
  117                         )
  118                     )
  119                 min_value = paramvalue.get('MinValue')
  120                 if min_value:
  121                     matches.extend(
  122                         self.check_min_value(
  123                             default_value, min_value, path
  124                         )
  125                     )
  126                 max_value = paramvalue.get('MaxValue')
  127                 if max_value is not None:
  128                     matches.extend(
  129                         self.check_max_value(
  130                             default_value, max_value, path
  131                         )
  132                     )
  133                 allowed_values = paramvalue.get('AllowedValues')
  134                 if allowed_values:
  135                     matches.extend(
  136                         self.check_allowed_values(
  137                             default_value, allowed_values, path
  138                         )
  139                     )
  140                 min_length = paramvalue.get('MinLength')
  141                 if min_length is not None:
  142                     matches.extend(
  143                         self.check_min_length(
  144                             default_value, min_length, path
  145                         )
  146                     )
  147                 max_length = paramvalue.get('MaxLength')
  148                 if max_length is not None:
  149                     matches.extend(
  150                         self.check_max_length(
  151                             default_value, max_length, path
  152                         )
  153                     )
  154 
  155         return matches
  156
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/src/cfnlint/rules/parameters/Default.py b/src/cfnlint/rules/parameters/Default.py
  --- a/src/cfnlint/rules/parameters/Default.py
  +++ b/src/cfnlint/rules/parameters/Default.py
  @@ -82,8 +82,9 @@
           """
           message = 'Default should have a length above or equal to MinLength'
   
  +        value = allowed_value if isinstance(allowed_value, six.string_types) else str(allowed_value)
           if isinstance(min_length, six.integer_types):
  -            if len(allowed_value) < min_length:
  +            if len(value) < min_length:
                   return([RuleMatch(path, message)])
   
           return []
  @@ -94,8 +95,9 @@
           """
           message = 'Default should have a length below or equal to MaxLength'
   
  +        value = allowed_value if isinstance(allowed_value, six.string_types) else str(allowed_value)
           if isinstance(max_length, six.integer_types):
  -            if len(allowed_value) > max_length:
  +            if len(value) > max_length:
                   return([RuleMatch(path, message)])
   
           return []
  
verification_info: {"golden_diff": "diff --git a/src/cfnlint/rules/parameters/Default.py b/src/cfnlint/rules/parameters/Default.py\n--- a/src/cfnlint/rules/parameters/Default.py\n+++ b/src/cfnlint/rules/parameters/Default.py\n@@ -82,8 +82,9 @@\n         \"\"\"\n         message = 'Default should have a length above or equal to MinLength'\n \n+        value = allowed_value if isinstance(allowed_value, six.string_types) else str(allowed_value)\n         if isinstance(min_length, six.integer_types):\n-            if len(allowed_value) < min_length:\n+            if len(value) < min_length:\n                 return([RuleMatch(path, message)])\n \n         return []\n@@ -94,8 +95,9 @@\n         \"\"\"\n         message = 'Default should have a length below or equal to MaxLength'\n \n+        value = allowed_value if isinstance(allowed_value, six.string_types) else str(allowed_value)\n         if isinstance(max_length, six.integer_types):\n-            if len(allowed_value) > max_length:\n+            if len(value) > max_length:\n                 return([RuleMatch(path, message)])\n \n         return []\n", "issue": "String misinterpreted as an int results in error on E2015\n```\r\ncfn-lint --version\r\ncfn-lint 0.19.1\r\n```\r\n\r\n*Description of issue.*\r\nThe following template\r\n```\r\nParameters:\r\n  CentralAccountId:\r\n    Default: 112233445566\r\n    MaxLength: 12\r\n    MinLength: 12\r\n    Type: String\r\n```\r\nresult in the error:\r\n```\r\nE0002 Unknown exception while processing rule E2015: object of type 'int' has no len()\r\napplication-account-initial-setup.yaml:1:1\r\n```\r\n\r\nIt is solved by putting quotes on the default value. However it is valid to not putting the quotes.\n", "before_files": [{"content": "\"\"\"\n  Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this\n  software and associated documentation files (the \"Software\"), to deal in the Software\n  without restriction, including without limitation the rights to use, copy, modify,\n  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n  permit persons to whom the Software is furnished to do so.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\"\"\"\nimport re\nimport six\nfrom cfnlint import CloudFormationLintRule\nfrom cfnlint import RuleMatch\n\n\nclass Default(CloudFormationLintRule):\n    \"\"\"Check if Parameters are configured correctly\"\"\"\n    id = 'E2015'\n    shortdesc = 'Default value is within parameter constraints'\n    description = 'Making sure the parameters have a default value inside AllowedValues, MinValue, MaxValue, AllowedPattern'\n    source_url = 'https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html'\n    tags = ['parameters']\n\n    def check_allowed_pattern(self, allowed_value, allowed_pattern, path):\n        \"\"\"\n            Check allowed value against allowed pattern\n        \"\"\"\n        message = 'Default should be allowed by AllowedPattern'\n        try:\n            if not re.match(allowed_pattern, str(allowed_value)):\n                return([RuleMatch(path, message)])\n        except re.error as ex:\n            self.logger.debug('Regex pattern \"%s\" isn\\'t supported by Python: %s', allowed_pattern, ex)\n\n        return []\n\n    def check_min_value(self, allowed_value, min_value, path):\n        \"\"\"\n            Check allowed value against min value\n        \"\"\"\n        message = 'Default should be equal to or higher than MinValue'\n\n        if isinstance(allowed_value, six.integer_types) and isinstance(min_value, six.integer_types):\n            if allowed_value < min_value:\n                return([RuleMatch(path, message)])\n\n        return []\n\n    def check_max_value(self, allowed_value, max_value, path):\n        \"\"\"\n            Check allowed value against max value\n        \"\"\"\n        message = 'Default should be less than or equal to MaxValue'\n\n        if isinstance(allowed_value, six.integer_types) and isinstance(max_value, six.integer_types):\n            if allowed_value > max_value:\n                return([RuleMatch(path, message)])\n\n        return []\n\n    def check_allowed_values(self, allowed_value, allowed_values, path):\n        \"\"\"\n            Check allowed value against allowed values\n        \"\"\"\n        message = 'Default should be a value within AllowedValues'\n\n        if allowed_value not in allowed_values:\n            return([RuleMatch(path, message)])\n\n        return []\n\n    def check_min_length(self, allowed_value, min_length, path):\n        \"\"\"\n            Check allowed value against MinLength\n        \"\"\"\n        message = 'Default should have a length above or equal to MinLength'\n\n        if isinstance(min_length, six.integer_types):\n            if len(allowed_value) < min_length:\n                return([RuleMatch(path, message)])\n\n        return []\n\n    def check_max_length(self, allowed_value, max_length, path):\n        \"\"\"\n            Check allowed value against MaxLength\n        \"\"\"\n        message = 'Default should have a length below or equal to MaxLength'\n\n        if isinstance(max_length, six.integer_types):\n            if len(allowed_value) > max_length:\n                return([RuleMatch(path, message)])\n\n        return []\n\n    def match(self, cfn):\n        \"\"\"Check CloudFormation Parameters\"\"\"\n\n        matches = []\n\n        for paramname, paramvalue in cfn.get_parameters().items():\n            default_value = paramvalue.get('Default')\n            if default_value is not None:\n                path = ['Parameters', paramname, 'Default']\n                allowed_pattern = paramvalue.get('AllowedPattern')\n                if allowed_pattern:\n                    matches.extend(\n                        self.check_allowed_pattern(\n                            default_value, allowed_pattern, path\n                        )\n                    )\n                min_value = paramvalue.get('MinValue')\n                if min_value:\n                    matches.extend(\n                        self.check_min_value(\n                            default_value, min_value, path\n                        )\n                    )\n                max_value = paramvalue.get('MaxValue')\n                if max_value is not None:\n                    matches.extend(\n                        self.check_max_value(\n                            default_value, max_value, path\n                        )\n                    )\n                allowed_values = paramvalue.get('AllowedValues')\n                if allowed_values:\n                    matches.extend(\n                        self.check_allowed_values(\n                            default_value, allowed_values, path\n                        )\n                    )\n                min_length = paramvalue.get('MinLength')\n                if min_length is not None:\n                    matches.extend(\n                        self.check_min_length(\n                            default_value, min_length, path\n                        )\n                    )\n                max_length = paramvalue.get('MaxLength')\n                if max_length is not None:\n                    matches.extend(\n                        self.check_max_length(\n                            default_value, max_length, path\n                        )\n                    )\n\n        return matches\n", "path": "src/cfnlint/rules/parameters/Default.py"}], "after_files": [{"content": "\"\"\"\n  Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this\n  software and associated documentation files (the \"Software\"), to deal in the Software\n  without restriction, including without limitation the rights to use, copy, modify,\n  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n  permit persons to whom the Software is furnished to do so.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\"\"\"\nimport re\nimport six\nfrom cfnlint import CloudFormationLintRule\nfrom cfnlint import RuleMatch\n\n\nclass Default(CloudFormationLintRule):\n    \"\"\"Check if Parameters are configured correctly\"\"\"\n    id = 'E2015'\n    shortdesc = 'Default value is within parameter constraints'\n    description = 'Making sure the parameters have a default value inside AllowedValues, MinValue, MaxValue, AllowedPattern'\n    source_url = 'https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html'\n    tags = ['parameters']\n\n    def check_allowed_pattern(self, allowed_value, allowed_pattern, path):\n        \"\"\"\n            Check allowed value against allowed pattern\n        \"\"\"\n        message = 'Default should be allowed by AllowedPattern'\n        try:\n            if not re.match(allowed_pattern, str(allowed_value)):\n                return([RuleMatch(path, message)])\n        except re.error as ex:\n            self.logger.debug('Regex pattern \"%s\" isn\\'t supported by Python: %s', allowed_pattern, ex)\n\n        return []\n\n    def check_min_value(self, allowed_value, min_value, path):\n        \"\"\"\n            Check allowed value against min value\n        \"\"\"\n        message = 'Default should be equal to or higher than MinValue'\n\n        if isinstance(allowed_value, six.integer_types) and isinstance(min_value, six.integer_types):\n            if allowed_value < min_value:\n                return([RuleMatch(path, message)])\n\n        return []\n\n    def check_max_value(self, allowed_value, max_value, path):\n        \"\"\"\n            Check allowed value against max value\n        \"\"\"\n        message = 'Default should be less than or equal to MaxValue'\n\n        if isinstance(allowed_value, six.integer_types) and isinstance(max_value, six.integer_types):\n            if allowed_value > max_value:\n                return([RuleMatch(path, message)])\n\n        return []\n\n    def check_allowed_values(self, allowed_value, allowed_values, path):\n        \"\"\"\n            Check allowed value against allowed values\n        \"\"\"\n        message = 'Default should be a value within AllowedValues'\n\n        if allowed_value not in allowed_values:\n            return([RuleMatch(path, message)])\n\n        return []\n\n    def check_min_length(self, allowed_value, min_length, path):\n        \"\"\"\n            Check allowed value against MinLength\n        \"\"\"\n        message = 'Default should have a length above or equal to MinLength'\n\n        value = allowed_value if isinstance(allowed_value, six.string_types) else str(allowed_value)\n        if isinstance(min_length, six.integer_types):\n            if len(value) < min_length:\n                return([RuleMatch(path, message)])\n\n        return []\n\n    def check_max_length(self, allowed_value, max_length, path):\n        \"\"\"\n            Check allowed value against MaxLength\n        \"\"\"\n        message = 'Default should have a length below or equal to MaxLength'\n\n        value = allowed_value if isinstance(allowed_value, six.string_types) else str(allowed_value)\n        if isinstance(max_length, six.integer_types):\n            if len(value) > max_length:\n                return([RuleMatch(path, message)])\n\n        return []\n\n    def match(self, cfn):\n        \"\"\"Check CloudFormation Parameters\"\"\"\n\n        matches = []\n\n        for paramname, paramvalue in cfn.get_parameters().items():\n            default_value = paramvalue.get('Default')\n            if default_value is not None:\n                path = ['Parameters', paramname, 'Default']\n                allowed_pattern = paramvalue.get('AllowedPattern')\n                if allowed_pattern:\n                    matches.extend(\n                        self.check_allowed_pattern(\n                            default_value, allowed_pattern, path\n                        )\n                    )\n                min_value = paramvalue.get('MinValue')\n                if min_value:\n                    matches.extend(\n                        self.check_min_value(\n                            default_value, min_value, path\n                        )\n                    )\n                max_value = paramvalue.get('MaxValue')\n                if max_value is not None:\n                    matches.extend(\n                        self.check_max_value(\n                            default_value, max_value, path\n                        )\n                    )\n                allowed_values = paramvalue.get('AllowedValues')\n                if allowed_values:\n                    matches.extend(\n                        self.check_allowed_values(\n                            default_value, allowed_values, path\n                        )\n                    )\n                min_length = paramvalue.get('MinLength')\n                if min_length is not None:\n                    matches.extend(\n                        self.check_min_length(\n                            default_value, min_length, path\n                        )\n                    )\n                max_length = paramvalue.get('MaxLength')\n                if max_length is not None:\n                    matches.extend(\n                        self.check_max_length(\n                            default_value, max_length, path\n                        )\n                    )\n\n        return matches\n", "path": "src/cfnlint/rules/parameters/Default.py"}]}