Closed richm closed 1 year ago
example of crash:
File "/builddir/build/BUILD/auto-maintenance-40e904d40dcfb8b522c91e525b2a0da24f9ad7ea/lsr_role2collection.py", line 1777, in <module>
sys.exit(role2collection())
^^^^^^^^^^^^^^^^^
File "/builddir/build/BUILD/auto-maintenance-40e904d40dcfb8b522c91e525b2a0da24f9ad7ea/lsr_role2collection.py", line 1384, in role2collection
copy_tree_with_replace(
File "/builddir/build/BUILD/auto-maintenance-40e904d40dcfb8b522c91e525b2a0da24f9ad7ea/lsr_role2collection.py", line 724, in copy_tree_with_replace
lsrxfrm.run()
File "/builddir/build/BUILD/auto-maintenance-40e904d40dcfb8b522c91e525b2a0da24f9ad7ea/lsr_role2collection.py", line 296, in run
lsrft.run()
File "/builddir/build/BUILD/auto-maintenance-40e904d40dcfb8b522c91e525b2a0da24f9ad7ea/lsr_role2collection.py", line 172, in run
self.handle_item(item)
File "/builddir/build/BUILD/auto-maintenance-40e904d40dcfb8b522c91e525b2a0da24f9ad7ea/lsr_role2collection.py", line 213, in handle_item
self.handle_task(item)
File "/builddir/build/BUILD/auto-maintenance-40e904d40dcfb8b522c91e525b2a0da24f9ad7ea/lsr_role2collection.py", line 230, in handle_task
self.task_cb(task)
File "/builddir/build/BUILD/auto-maintenance-40e904d40dcfb8b522c91e525b2a0da24f9ad7ea/lsr_role2collection.py", line 534, in task_cb
task.insert(idx, self.prefix + role_module_name, val)
File "/usr/lib/python3.11/site-packages/ruamel/yaml/comments.py", line 818, in insert
self.move_to_end(keys[idx])
~~~~^^^^^
IndexError: list index out of range
The old code would delete the old key using
pop
which would also retrieve the value of the old key, then insert the new key with the value at the old index. This causes ruamel 0.17.23 and later to crash with an "index out of range" error. Instead, retrieve the value, then insert the value with the new key at the old index, then finally delete the old key.