Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ruamel now requires insertion of new key then deletion #272

Merged
merged 1 commit into from May 16, 2023

Conversation

richm
Copy link
Contributor

@richm richm commented May 16, 2023

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.

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.
@richm
Copy link
Contributor Author

richm commented May 16, 2023

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

@richm richm merged commit 5fa4921 into linux-system-roles:master May 16, 2023
4 checks passed
@richm richm deleted the insert-key-then-remove branch May 16, 2023 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant