Closed mateusz-nowak-mox closed 4 years ago
Example 1
resource "test" "this" { profile = jsonencode( { "a" : true } ) }
Error: TypeError: ('%s is of type %s; expected type of dict, list, tuple, or str', 'True', <class 'bool'>)
TypeError: ('%s is of type %s; expected type of dict, list, tuple, or str', 'True', <class 'bool'>)
Debug:
State : 0 Stack : . LexToken(IDENTIFIER,'resource',5,84) Action : Shift and goto state 8 State : 8 Stack : IDENTIFIER . LexToken(STRING,'test',5,98) Action : Reduce rule [objectkey -> IDENTIFIER] with ['resource'] and goto state 5 p_objectkey_0: None | resource Result : <str @ 0x7f8ec186b470> ('resource') State : 5 Stack : objectkey . LexToken(STRING,'test',5,98) Action : Shift and goto state 7 State : 7 Stack : objectkey STRING . LexToken(STRING,'this',5,105) Action : Reduce rule [objectkey -> STRING] with ['test'] and goto state 19 p_objectkey_0: None | test Result : <str @ 0x7f8ec186bf30> ('test') State : 19 Stack : objectkey objectkey . LexToken(STRING,'this',5,105) Action : Shift and goto state 7 State : 7 Stack : objectkey objectkey STRING . LexToken(LEFTBRACE,'{',5,107) Action : Reduce rule [objectkey -> STRING] with ['this'] and goto state 19 p_objectkey_0: None | this Result : <str @ 0x7f8ec1f7df70> ('this') State : 19 Stack : objectkey objectkey objectkey . LexToken(LEFTBRACE,'{',5,107) Action : Shift and goto state 24 State : 24 Stack : objectkey objectkey objectkey LEFTBRACE . LexToken(IDENTIFIER,'profile',6,111) Action : Shift and goto state 8 State : 8 Stack : objectkey objectkey objectkey LEFTBRACE IDENTIFIER . LexToken(EQUAL,'=',6,119) Action : Reduce rule [objectkey -> IDENTIFIER] with ['profile'] and goto state 5 p_objectkey_0: None | profile Result : <str @ 0x7f8ec18ee2f0> ('profile') State : 5 Stack : objectkey objectkey objectkey LEFTBRACE objectkey . LexToken(EQUAL,'=',6,119) Action : Shift and goto state 20 State : 20 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL . LexToken(IDENTIFIER,'jsonencode',6,121) Action : Shift and goto state 44 State : 44 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER . LexToken(LEFTPAREN,'(',6,131) Action : Shift and goto state 91 State : 91 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN . LexToken(LEFTBRACE,'{',7,137) Action : Shift and goto state 24 State : 24 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN LEFTBRACE . LexToken(STRING,'a',8,147) Action : Shift and goto state 7 State : 7 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN LEFTBRACE STRING . LexToken(COLON,':',8,149) Action : Reduce rule [objectkey -> STRING] with ['a'] and goto state 5 p_objectkey_0: None | a Result : <str @ 0x7f8ec2239ef0> ('a') State : 5 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN LEFTBRACE objectkey . LexToken(COLON,':',8,149) Action : Shift and goto state 22 State : 22 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN LEFTBRACE objectkey COLON . LexToken(BOOL,True,8,151) Action : Shift and goto state 54 State : 54 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN LEFTBRACE objectkey COLON BOOL . LexToken(RIGHTBRACE,'}',9,160) Action : Reduce rule [objectitem -> objectkey COLON BOOL] with ['a',':',True] and goto state 4 p_objectitem_0: None | a | : | True Result : <tuple @ 0x7f8ec1849730> (('a', True)) State : 4 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN LEFTBRACE objectitem . LexToken(RIGHTBRACE,'}',9,160) Action : Reduce rule [objectlist -> objectitem] with [('a', True)] and goto state 61 p_objectlist_0: None | ('a', True) Result : <list @ 0x7f8ec1886460> ([('a', True)]) State : 61 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN LEFTBRACE objectlist . LexToken(RIGHTBRACE,'}',9,160) Action : Shift and goto state 105 State : 105 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN LEFTBRACE objectlist RIGHTBRACE . LexToken(RIGHTPAREN,')',10,164) Action : Reduce rule [object -> LEFTBRACE objectlist RIGHTBRACE] with ['{',[('a', True)],'}'] and goto state 97 p_object_0: None | { | [('a', True)] | } Result : <dict @ 0x7f8ec1a2b280> ({'a': True}) State : 97 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN object . LexToken(RIGHTPAREN,')',10,164) Action : Reduce rule [listitem -> object] with [{'a': True}] and goto state 95 p_listitem_0: None | {'a': True} Result : <dict @ 0x7f8ec1a2b280> ({'a': True}) State : 95 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN listitem . LexToken(RIGHTPAREN,')',10,164) Action : Reduce rule [listitems -> listitem] with [{'a': True}] and goto state 121 p_listitems_0: None | {'a': True} Result : <list @ 0x7f8ec1886460> ([{'a': True}]) State : 121 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN listitems . LexToken(RIGHTPAREN,')',10,164) Action : Shift and goto state 144 State : 144 Stack : objectkey objectkey objectkey LEFTBRACE objectkey EQUAL IDENTIFIER LEFTPAREN listitems RIGHTPAREN . LexToken(RIGHTBRACE,'}',11,166) Action : Reduce rule [function -> IDENTIFIER LEFTPAREN listitems RIGHTPAREN] with ['jsonencode','(',[{'a': True}],')'] and goto state 48 p_function_0: None | jsonencode | ( | [{'a': True}] | )
Parser doesn't seem to understand boolean variables nested in jsoncode function.
pyhcl doesn't support HCL2, try https://pypi.org/project/python-hcl2/ instead.
Example 1
Error:
TypeError: ('%s is of type %s; expected type of dict, list, tuple, or str', 'True', <class 'bool'>)
Debug:
Parser doesn't seem to understand boolean variables nested in jsoncode function.