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
285 stars 26 forks source link

Exception raised when iambic plan command is run on empty template file #577

Closed 0xAJX closed 1 year ago

0xAJX commented 1 year ago

The bug

An exception is thrown when 'iambic plan' is run on an empty template file.

To Reproduce

Run the command 'iambic plan' on an empty template file.

Expected behaviour

The command should not show a TypeError("'NoneType' object does not support item assignment") error when the template file is empty

Desktop

Error Traceback

2023/08/16 18:51:57 [error ] Unhandled Exception
error=TypeError("'NoneType' object does not support item assignment") exception=TypeError 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 sys.exit(cli()) ^^^^^ File "redacted\click\core.py", line 1157, in call return self.main(*args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "redacted\click\core.py", line 1078, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "redacted\click\core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "redacted\click\core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 388, in run_plan asyncio.run(flag_expired_resources(templates, config.template_map)) File "redacted\Python\Python311\Lib\asyncio\runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "redacted\Python\Python311\Lib\asyncio\runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "redacted\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "redacted\iambic\request_handler\expire_resources.py", line 24, in flag_expired_resources for template in load_templates(template_paths, template_map) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "redacted\iambic\core\parser.py", line 108, in load_templates template_dicts = p.map(load_template_fn, template_paths) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "redacted\Python\Python311\Lib\multiprocessing\pool.py", line 367, in map return self._map_async(func, iterable, mapstar, chunksize).get() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "redacted\Python\Python311\Lib\multiprocessing\pool.py", line 774, in get raise self._value

0xAJX commented 1 year ago

Pull Request for this Issue

smoy commented 1 year ago

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