question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove try... convert of integers (E3002)

See original GitHub issue

In the property Type check, when the property value should be an integer (but it’s not), there is an attempt to convert it:

https://github.com/awslabs/cfn-python-lint/blob/master/src/cfnlint/rules/resources/properties/Properties.py#L56

Since both YAML and JSON just handle these types out the box, the try..except can in theory be removed (since the type’s don’t match, a string is not an integer).

Personally I like the check to be more "strict’, who do other think?

Example (JSON): https://github.com/awslabs/cfn-python-lint/blob/master/test/templates/quickstart/vpc-management.json#L816

Example (YAML): https://github.com/awslabs/cfn-python-lint/blob/master/test/templates/good/resource_properties.yaml#L464

These values can easily be written as actual integers

      - CidrIp:
          Ref: SSHLocation
        FromPort: 22 
        IpProtocol: tcp
        ToPort: 22

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
finchdcommented, May 23, 2018

Yes, it definitely fails to create the stack: “Value of property Value must be of type String” aws cloudformation validate-template succeeds with no errors either.

0reactions
fatbasstardcommented, May 28, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove try... convert of integers (E3002) · Issue #42 - GitHub
In the property Type check, when the property value should be an integer (but it's not), there is an attempt to convert it:....
Read more >
Issues with try/except, attempting to convert strings to integers ...
I've tried the try/except statements in multiple ways and none of them return a df. The current code for example returns an 'int'...
Read more >
how to remove'- ' in the integer value - SQLServerCentral
The Source Column has larg Text and is of Data Type "four-byte signed integer [DT_I4]". Then when i try the RAPLACE like =...
Read more >
TRY_CONVERT (Transact-SQL) - SQL Server - Microsoft Learn
The result of this statement is an error, because an integer cannot be cast into an xml data type. Copy. Explicit conversion from...
Read more >
How to Convert a Python String to int
There are several ways to represent integers in Python. In this quick and practical tutorial, you'll learn how you can store integers using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found