noqdev / iambic

IAMbic is Version-Control for IAM. It centralizes and simplifies cloud access and permissions. It maintains an eventually consistent, human-readable, bi-directional representation of IAM in Git.
https://iambic.org
Apache License 2.0
283 stars 26 forks source link

Encoding error when writing proposed_changes.txt file #575

Closed 0xAJX closed 1 year ago

0xAJX commented 1 year ago

The bug

When 'iambic plan' command is run on updated yaml file(s) the changes should be written to a proposed_changes.txt file. But 'UnicodeEncodeError' exception occurs. Error Traceback is added at the end for reference.

To Reproduce

Run 'iambic plan' command on updated yaml file(s)

Expected behavior

Should write proposed_changes.txt file without any error

Desktop

Error Traceback

2023/08/16 11:54:54 [error ] Unhandled Exception
error=UnicodeEncodeError('charmap', 'IAMbic Summary\r\n\r\nChange Detection\r\n\r\n 1 Update actions.\r\n 1 templates with changes.\r\n 1 accounts affected.\r\n\r\nIAMbic Change Details\r\nUpdate\r\n└── resources/aws/iam/ma naged_policy/redacted redacted/ssm-parameter-store-access.yaml\r\n └── redacted redacted - (redacted)\r\n └── aws:policy_document // arn:aws:iam::redacted:policy/ssm-parameter-store-access\r\n └── policy _document:\r\n -iterable_item_removed\r\n {"root[\'Statement\'][0][\'Action\'][1]": \'ssm:DeleteParameter\', "root[\'Statement\'][0][\'Action\'][5]": \'ssm:DeleteParameters\'}\r\n', 145, 148, 'chara cter maps to ') exception=UnicodeEncodeError stacktrace= File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "redacted\venv\Scripts\iambic.exe__main.py", line 7, in ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "redacted\click\core.py", line 783, in invoke return callback(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "redacted\iambic\main.py", line 360, in plan run_plan(templates, repo_dir=repo_dir) File "redacted\iambic\main.py", line 400, in run_plan output_proposed_changes(template_changes) File "redacted\iambic\main.py", line 54, in output_proposed_changes file_render_resource_changes(output_path, template_changes) File "redacted\iambic\output\text.py", line 25, in file_render_resource_changes f.write(rendered_data) File "redacted\Python\Python311\Lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0xAJX commented 1 year ago

Pull Request

smoy commented 1 year ago

Fix is included in iambic-core 0.11.48, available in PyPi