Repository navigation
Closed
Labels
bugSomething isn't working
Description
Hi,
Since the upgrade to 6.0.0 the following Terraform fails to parse:
locals {
loop = { for k, v in data.aws_iam_policy_document.inline_policy : k => v if v.statement != null }
}
This appears to be related to the v.statement != null part. The following hypotheticals all work:
if v.statement != "null"
if v.statement != 1
if v.statement != []
if v.statement
Also, the symbols don't matter, tried with ==, >, etc and they all similarly fail if compared with null.
A workaround for the moment is this sort of thing:
locals {
loop = { for k, v in data.aws_iam_policy_document.inline_policy : k => v if can(coalesce(v.statement)) }
}
coalesce() will error if v.statement is null, which gets caught by can() to evaluate as false. However, this will also evaluate to false if v.statement is the empty string, so it's not identical to != null.
Below is the full stacktrace:
Traceback (most recent call last):
File "/Users/mattcarrick/repos/lc-39/azure-sso/bin/unique.py", line 14, in <module>
for local in hcl2.load(file)["locals"]:
^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/hcl2/api.py", line 15, in load
return loads(file.read(), with_meta=with_meta)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/hcl2/api.py", line 29, in loads
return DictTransformer(with_meta=with_meta).transform(tree)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 161, in transform
return self._transform_tree(tree)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 156, in _transform_tree
children = list(self._transform_children(tree.children))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 146, in _transform_children
res = self._transform_tree(c)
^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 156, in _transform_tree
children = list(self._transform_children(tree.children))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 146, in _transform_children
res = self._transform_tree(c)
^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 156, in _transform_tree
children = list(self._transform_children(tree.children))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 146, in _transform_children
res = self._transform_tree(c)
^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 156, in _transform_tree
children = list(self._transform_children(tree.children))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 146, in _transform_children
res = self._transform_tree(c)
^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 156, in _transform_tree
children = list(self._transform_children(tree.children))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 146, in _transform_children
res = self._transform_tree(c)
^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 156, in _transform_tree
children = list(self._transform_children(tree.children))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 146, in _transform_children
res = self._transform_tree(c)
^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 156, in _transform_tree
children = list(self._transform_children(tree.children))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 146, in _transform_children
res = self._transform_tree(c)
^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 156, in _transform_tree
children = list(self._transform_children(tree.children))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 146, in _transform_children
res = self._transform_tree(c)
^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 156, in _transform_tree
children = list(self._transform_children(tree.children))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 146, in _transform_children
res = self._transform_tree(c)
^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 157, in _transform_tree
return self._call_userfunc(tree, children)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/lark/visitors.py", line 128, in _call_userfunc
raise VisitError(tree.data, tree, e)
lark.exceptions.VisitError: Error trying to process rule "binary_term":
Invalid type to convert to inline HCL: <class 'NoneType'>
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
kkozik-amplify commentedon Jan 21, 2025
Hey @xRokco, thanks for taking time to report this.
The issue was already fixed in #184 and we're hoping to release it at the end of this week
xRokco commentedon Jan 21, 2025
Ah, my bad for not seeing it. Cheers!
v6.1.0 release (#187)