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

IndexError: list index out of range #125

Open
ZeroDevNull opened this issue Nov 11, 2023 · 3 comments
Open

IndexError: list index out of range #125

ZeroDevNull opened this issue Nov 11, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@ZeroDevNull
Copy link

OS: Ubuntu 20.04
XMLDIFF version: 2.4/2.6.3

When I diff these two files I get the following error:

Traceback (most recent call last):
  File "/data/usr/bin/xmlpatch", line 11, in <module>
    load_entry_point('xmldiff==2.4', 'console_scripts', 'xmlpatch')()
  File "/data/usr/lib/python3/dist-packages/xmldiff/main.py", line 171, in patch_command
    result = patch_file(args.patchfile, args.xmlfile)
  File "/data/usr/lib/python3/dist-packages/xmldiff/main.py", line 148, in patch_file
    tree = patch_tree(actions, tree)
  File "/data/usr/lib/python3/dist-packages/xmldiff/main.py", line 124, in patch_tree
    return patcher.patch(actions, tree)
  File "/data/usr/lib/python3/dist-packages/xmldiff/patch.py", line 15, in patch
    self.handle_action(action, result)
  File "/data/usr/lib/python3/dist-packages/xmldiff/patch.py", line 22, in handle_action
    method(action, tree)
  File "/data/usr/lib/python3/dist-packages/xmldiff/patch.py", line 34, in _handle_RenameNode
    tree.xpath(action.node)[0].tag = action.tag
IndexError: list index out of range

The commands I run are:
xmldiff cfgspawnabletypes1.xml cfgspawnabletypes2.xml > cfgspawnabletypes.diff
xmlpatch cfgspawnabletypes.diff cfgspawnabletypes1.xml

The exact files used:
xmltest.zip

I've tried to remove all whitepaces and comments but that didn't work.

@regebro
Copy link
Contributor

regebro commented Jan 4, 2024

Well, this is a bug, but these files are huge, and almost every single item has changed, so it's practically impossible to debug this. There are 550 actions before the one that fails, and to figure out why this one fails, I would have to step through all of them and see how they affect the state of the tree to figure out what goes wrong, because it's somewhere in the preceding 550 actions.

If you can make a smaller case with a similar error that could be helpful.

Also, the diffs are larger than the original file, so I'm not sure what the purpose of diffing and patching is in this case.

@regebro regebro added the bug Something isn't working label Jan 4, 2024
@Ymil
Copy link

Ymil commented Jan 19, 2024

Hello, I have a similar problem, this is my error message, is it equivalent?

  File "/venv/lib/python3.8/site-packages/xmldiff/main.py", line 50, in diff_files
    return _diff(etree.parse, left, right,
  File "/venv/lib/python3.8/site-packages/xmldiff/main.py", line 38, in _diff
    return diff_trees(left_tree, right_tree, diff_options=diff_options,
  File "/venv/lib/python3.8/site-packages/xmldiff/main.py", line 30, in diff_trees
    return formatter.format(diffs, left)
  File "/venv/lib/python3.8/site-packages/xmldiff/formatting.py", line 717, in format
    actions.extend(self.handle_action(action, orig_tree))
  File "/venv/lib/python3.8/site-packages/xmldiff/formatting.py", line 727, in handle_action
    for item in method(action, orig_tree):
  File "/venv/lib/python3.8/site-packages/xmldiff/formatting.py", line 758, in _handle_MoveNode
    node = orig_tree.xpath(action.node)[0]
IndexError: list index out of range

@regebro
Copy link
Contributor

regebro commented Jan 19, 2024

No, but it may be related. Again, if someone could make a smaller example where this happens I should have time to look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants