prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  cfn-lint throws error when !ToJsonString contains int value
  ### CloudFormation Lint Version
  
  0.76.2
  
  ### What operating system are you using?
  
  Ubuntu
  
  ### Describe the bug
  
  Unexpected internal error during linting of rule E1031, involving `ToJsonString` of numerical value
  
  ```
  2023-04-06 20:20:31,922 - cfnlint - DEBUG - Completed linting of file: templates/lambda.yml
  E0002 Unknown exception while processing rule E1031: Traceback (most recent call last):
    File "/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/rules/__init__.py", line 320, in run_check
      return check(*args)
    File "/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/rules/__init__.py", line 44, in wrapper
      results = match_function(self, filename, cfn, *args, **kwargs)
    File "/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/rules/__init__.py", line 202, in matchall
      return self.match(cfn)  # pylint: disable=E1102
    File "/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/rules/functions/ToJsonString.py", line 39, in match
      LanguageExtensions.validate_pseudo_parameters(
    File "/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/languageExtensions.py", line 32, in validate_pseudo_parameters
      ref_list = [val[ref] for key, val in fn_object_val.items() if ref in val]
    File "/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/languageExtensions.py", line 32, in <listcomp>
      ref_list = [val[ref] for key, val in fn_object_val.items() if ref in val]
  TypeError: argument of type 'int' is not iterable
  
  cfn-secrets-stack.yml:1:1
  
  E0002 Unknown exception while processing rule E1031: Traceback (most recent call last):
    File "/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/rules/__init__.py", line 320, in run_check
      return check(*args)
    File "/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/rules/__init__.py", line 44, in wrapper
      results = match_function(self, filename, cfn, *args, **kwargs)
    File "/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/rules/__init__.py", line 202, in matchall
      return self.match(cfn)  # pylint: disable=E1102
    File "/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/rules/functions/ToJsonString.py", line 39, in match
      LanguageExtensions.validate_pseudo_parameters(
    File "/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/languageExtensions.py", line 32, in validate_pseudo_parameters
      ref_list = [val[ref] for key, val in fn_object_val.items() if ref in val]
    File "/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/languageExtensions.py", line 32, in <listcomp>
      ref_list = [val[ref] for key, val in fn_object_val.items() if ref in val]
  TypeError: argument of type 'int' is not iterable
  
  cfn-secrets-stack.yml:1:1
  ```
  
  ### Expected behavior
  
  String quoted int should work as well as int, both are valid json
  
  ### Reproduction template
  
  This works
  ```yaml
  Resources:
    DeploymentProperties:
      Properties:
        Description: "testing"
        Name: 'Test'
        SecretString: !ToJsonString
          SomeNumber: '3'
      Type: AWS::SecretsManager::Secret
  Transform: AWS::LanguageExtensions
  ```
  
  This does not, with the above error
  ```yaml
  Resources:
    DeploymentProperties:
      Properties:
        Description: "testing"
        Name: 'Test'
        SecretString: !ToJsonString
          SomeNumber: 3
      Type: AWS::SecretsManager::Secret
  Transform: AWS::LanguageExtensions
  ```
  
  
  </issue>
  <code>
  [start of src/cfnlint/languageExtensions.py]
  1 from cfnlint.rules import RuleMatch
  2 
  3 
  4 class LanguageExtensions:
  5     """Class for a CloudFormation languageExtensions"""
  6 
  7     def validate_transform_is_declared(
  8         self, has_language_extensions_transform, matches, tree, intrinsic_function
  9     ):
  10         if not has_language_extensions_transform:
  11             message = (
  12                 "Missing Transform: Declare the AWS::LanguageExtensions Transform globally to enable use"
  13                 " of the intrinsic function " + intrinsic_function + " at {0}"
  14             )
  15             matches.append(RuleMatch(tree[:], message.format("/".join(map(str, tree)))))
  16         return matches
  17 
  18     def validate_type(self, fn_object_val, matches, tree, intrinsic_function):
  19         if not isinstance(fn_object_val, dict) and not isinstance(fn_object_val, list):
  20             message = intrinsic_function + " needs a map or a list at {0}"
  21             matches.append(RuleMatch(tree[:], message.format("/".join(map(str, tree)))))
  22         elif len(fn_object_val) == 0:
  23             message = "Invalid value for " + intrinsic_function + " for {0}"
  24             matches.append(RuleMatch(tree[:], message.format("/".join(map(str, tree)))))
  25         return matches
  26 
  27     def validate_pseudo_parameters(
  28         self, fn_object_val, matches, tree, pseudo_params, intrinsic_function
  29     ):
  30         if isinstance(fn_object_val, dict):
  31             ref = "Ref"
  32             ref_list = [val[ref] for key, val in fn_object_val.items() if ref in val]
  33             for ref in ref_list:
  34                 if ref in pseudo_params:
  35                     message = (
  36                         intrinsic_function
  37                         + " does not support the pseudo parameter "
  38                         + ref
  39                         + " for {0}"
  40                     )
  41                     matches.append(
  42                         RuleMatch(tree[:], message.format("/".join(map(str, tree))))
  43                     )
  44         return matches
  45
  [end of src/cfnlint/languageExtensions.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/src/cfnlint/languageExtensions.py b/src/cfnlint/languageExtensions.py
  --- a/src/cfnlint/languageExtensions.py
  +++ b/src/cfnlint/languageExtensions.py
  @@ -29,7 +29,11 @@
       ):
           if isinstance(fn_object_val, dict):
               ref = "Ref"
  -            ref_list = [val[ref] for key, val in fn_object_val.items() if ref in val]
  +            ref_list = [
  +                val[ref]
  +                for _, val in fn_object_val.items()
  +                if hasattr(val, "__iter__") and ref in val
  +            ]
               for ref in ref_list:
                   if ref in pseudo_params:
                       message = (
  
verification_info: {"golden_diff": "diff --git a/src/cfnlint/languageExtensions.py b/src/cfnlint/languageExtensions.py\n--- a/src/cfnlint/languageExtensions.py\n+++ b/src/cfnlint/languageExtensions.py\n@@ -29,7 +29,11 @@\n     ):\n         if isinstance(fn_object_val, dict):\n             ref = \"Ref\"\n-            ref_list = [val[ref] for key, val in fn_object_val.items() if ref in val]\n+            ref_list = [\n+                val[ref]\n+                for _, val in fn_object_val.items()\n+                if hasattr(val, \"__iter__\") and ref in val\n+            ]\n             for ref in ref_list:\n                 if ref in pseudo_params:\n                     message = (\n", "issue": "cfn-lint throws error when !ToJsonString contains int value\n### CloudFormation Lint Version\n\n0.76.2\n\n### What operating system are you using?\n\nUbuntu\n\n### Describe the bug\n\nUnexpected internal error during linting of rule E1031, involving `ToJsonString` of numerical value\r\n\r\n```\r\n2023-04-06 20:20:31,922 - cfnlint - DEBUG - Completed linting of file: templates/lambda.yml\r\nE0002 Unknown exception while processing rule E1031: Traceback (most recent call last):\r\n  File \"/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/rules/__init__.py\", line 320, in run_check\r\n    return check(*args)\r\n  File \"/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/rules/__init__.py\", line 44, in wrapper\r\n    results = match_function(self, filename, cfn, *args, **kwargs)\r\n  File \"/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/rules/__init__.py\", line 202, in matchall\r\n    return self.match(cfn)  # pylint: disable=E1102\r\n  File \"/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/rules/functions/ToJsonString.py\", line 39, in match\r\n    LanguageExtensions.validate_pseudo_parameters(\r\n  File \"/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/languageExtensions.py\", line 32, in validate_pseudo_parameters\r\n    ref_list = [val[ref] for key, val in fn_object_val.items() if ref in val]\r\n  File \"/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/languageExtensions.py\", line 32, in <listcomp>\r\n    ref_list = [val[ref] for key, val in fn_object_val.items() if ref in val]\r\nTypeError: argument of type 'int' is not iterable\r\n\r\ncfn-secrets-stack.yml:1:1\r\n\r\nE0002 Unknown exception while processing rule E1031: Traceback (most recent call last):\r\n  File \"/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/rules/__init__.py\", line 320, in run_check\r\n    return check(*args)\r\n  File \"/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/rules/__init__.py\", line 44, in wrapper\r\n    results = match_function(self, filename, cfn, *args, **kwargs)\r\n  File \"/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/rules/__init__.py\", line 202, in matchall\r\n    return self.match(cfn)  # pylint: disable=E1102\r\n  File \"/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/rules/functions/ToJsonString.py\", line 39, in match\r\n    LanguageExtensions.validate_pseudo_parameters(\r\n  File \"/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/languageExtensions.py\", line 32, in validate_pseudo_parameters\r\n    ref_list = [val[ref] for key, val in fn_object_val.items() if ref in val]\r\n  File \"/home/kftse/anaconda3/envs/aws/lib/python3.10/site-packages/cfnlint/languageExtensions.py\", line 32, in <listcomp>\r\n    ref_list = [val[ref] for key, val in fn_object_val.items() if ref in val]\r\nTypeError: argument of type 'int' is not iterable\r\n\r\ncfn-secrets-stack.yml:1:1\r\n```\n\n### Expected behavior\n\nString quoted int should work as well as int, both are valid json\n\n### Reproduction template\n\nThis works\r\n```yaml\r\nResources:\r\n  DeploymentProperties:\r\n    Properties:\r\n      Description: \"testing\"\r\n      Name: 'Test'\r\n      SecretString: !ToJsonString\r\n        SomeNumber: '3'\r\n    Type: AWS::SecretsManager::Secret\r\nTransform: AWS::LanguageExtensions\r\n```\r\n\r\nThis does not, with the above error\r\n```yaml\r\nResources:\r\n  DeploymentProperties:\r\n    Properties:\r\n      Description: \"testing\"\r\n      Name: 'Test'\r\n      SecretString: !ToJsonString\r\n        SomeNumber: 3\r\n    Type: AWS::SecretsManager::Secret\r\nTransform: AWS::LanguageExtensions\r\n```\r\n\n", "before_files": [{"content": "from cfnlint.rules import RuleMatch\n\n\nclass LanguageExtensions:\n    \"\"\"Class for a CloudFormation languageExtensions\"\"\"\n\n    def validate_transform_is_declared(\n        self, has_language_extensions_transform, matches, tree, intrinsic_function\n    ):\n        if not has_language_extensions_transform:\n            message = (\n                \"Missing Transform: Declare the AWS::LanguageExtensions Transform globally to enable use\"\n                \" of the intrinsic function \" + intrinsic_function + \" at {0}\"\n            )\n            matches.append(RuleMatch(tree[:], message.format(\"/\".join(map(str, tree)))))\n        return matches\n\n    def validate_type(self, fn_object_val, matches, tree, intrinsic_function):\n        if not isinstance(fn_object_val, dict) and not isinstance(fn_object_val, list):\n            message = intrinsic_function + \" needs a map or a list at {0}\"\n            matches.append(RuleMatch(tree[:], message.format(\"/\".join(map(str, tree)))))\n        elif len(fn_object_val) == 0:\n            message = \"Invalid value for \" + intrinsic_function + \" for {0}\"\n            matches.append(RuleMatch(tree[:], message.format(\"/\".join(map(str, tree)))))\n        return matches\n\n    def validate_pseudo_parameters(\n        self, fn_object_val, matches, tree, pseudo_params, intrinsic_function\n    ):\n        if isinstance(fn_object_val, dict):\n            ref = \"Ref\"\n            ref_list = [val[ref] for key, val in fn_object_val.items() if ref in val]\n            for ref in ref_list:\n                if ref in pseudo_params:\n                    message = (\n                        intrinsic_function\n                        + \" does not support the pseudo parameter \"\n                        + ref\n                        + \" for {0}\"\n                    )\n                    matches.append(\n                        RuleMatch(tree[:], message.format(\"/\".join(map(str, tree))))\n                    )\n        return matches\n", "path": "src/cfnlint/languageExtensions.py"}]}