Skip to content

Conversation

zas
Copy link
Collaborator

@zas zas commented Sep 7, 2025

  • index < 0 was handled
  • index >= len(self._columns) wasn't (it happened when switching between different branches, it shouldn't during normal use)
  • so be more defensive and catch IndexError (and log it as warning)

Original error was:

Traceback (most recent call last):
  File "/home/zas/src/picard/picard/ui/widgets/configurablecolumnsheader.py", line 130, in on_sort_indicator_changed
    if index < 0 or not self._columns[index].sortable:
                        ~~~~~~~~~~~~~^^^^^^^
  File "/home/zas/src/picard/picard/ui/columns.py", line 167, in __getitem__
    return self._list.__getitem__(index)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
IndexError: list index out of range

Summary

  • This is a…
    • Bug fix
    • Feature addition
    • Refactoring
    • Minor / simple change (like a typo)
    • Other
  • Describe this change in 1-2 sentences:

Problem

  • JIRA ticket (optional): PICARD-XXX

Solution

Action

Additional actions required:

  • Update Picard documentation (please include a reference to this PR)
  • Other (please specify below)

- index < 0 was handled
- index >= len(self._columns) wasn't (it happened when switching between different branches, it shouldn't during normal use)
- so be more defensive and catch IndexError (and log it as warning)

Original error was:

```
Traceback (most recent call last):
  File "/home/zas/src/picard/picard/ui/widgets/configurablecolumnsheader.py", line 130, in on_sort_indicator_changed
    if index < 0 or not self._columns[index].sortable:
                        ~~~~~~~~~~~~~^^^^^^^
  File "/home/zas/src/picard/picard/ui/columns.py", line 167, in __getitem__
    return self._list.__getitem__(index)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
IndexError: list index out of range
```
@zas zas requested a review from phw September 7, 2025 19:35
Copy link
Collaborator

@rdswift rdswift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Copy link
Member

@phw phw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zas zas merged commit ce0d34d into metabrainz:master Sep 8, 2025
45 checks passed
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.

3 participants