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

Early Edits fail to process #37

Open
bjfranks opened this issue Feb 15, 2023 · 2 comments
Open

Early Edits fail to process #37

bjfranks opened this issue Feb 15, 2023 · 2 comments
Labels
non-strict parsing bugs related to malformed simfiles that StepMania accepts
Milestone

Comments

@bjfranks
Copy link

So, I was just going through files trying to count game elements and noticed that whenever an empty edit came up, the library crashed due to a list index being out of range. Here are three similar errors. For each, I give the file name and the index of the chart failing, followed by the stack trace. Find the files attached:

Dance Vibrations 2
Traceback (most recent call last):
  File "...", line 10, in calculate_statistics
    note_data = NoteData(simfileInstance.charts[chart])
  File "D:\Meatball\venv\lib\site-packages\simfile\notes\__init__.py", line 136, in __init__
    self._columns = NoteData._get_columns(self._notedata)
  File "D:\Meatball\venv\lib\site-packages\simfile\notes\__init__.py", line 142, in _get_columns
    first_line = first_measure.strip().splitlines()[0].strip()
IndexError: list index out of range

That Is Fair 4
Traceback (most recent call last):
  File "...", line 10, in calculate_statistics
    note_data = NoteData(simfileInstance.charts[chart])
  File "D:\Meatball\venv\lib\site-packages\simfile\notes\__init__.py", line 136, in __init__
    self._columns = NoteData._get_columns(self._notedata)
  File "D:\Meatball\venv\lib\site-packages\simfile\notes\__init__.py", line 142, in _get_columns
    first_line = first_measure.strip().splitlines()[0].strip()
IndexError: list index out of range

Virtual Emotion 0
Traceback (most recent call last):
  File "...", line 10, in calculate_statistics
    note_data = NoteData(simfileInstance.charts[chart])
  File "D:\Meatball\venv\lib\site-packages\simfile\notes\__init__.py", line 136, in __init__
    self._columns = NoteData._get_columns(self._notedata)
  File "D:\Meatball\venv\lib\site-packages\simfile\notes\__init__.py", line 142, in _get_columns
    first_line = first_measure.strip().splitlines()[0].strip()
IndexError: list index out of range

files.zip

@garcia garcia added the non-strict parsing bugs related to malformed simfiles that StepMania accepts label Feb 18, 2023
@garcia
Copy link
Owner

garcia commented Apr 7, 2023

The reason this happens is because NoteData determines the number of columns by looking at the first non-empty line of note data. This doesn't work when the note data is completely empty. I might set it to 0 for these cases. Another option would be to define a static mapping of stepstypes to column counts (dance-single → 4, dance-double → 8, etc.) but I'd like to avoid that pattern as much as possible.

@garcia
Copy link
Owner

garcia commented Jun 18, 2024

Another option would be to define a static mapping of stepstypes to column counts (dance-single → 4, dance-double → 8, etc.)

Upon further reflection, I think that this is not only a reasonable fix for the bug, but makes more sense as the default method for determining column count than the current behavior ("looking at the first non-empty line of note data"). Will have to think some more about whether empty note data should even be considered a strict parse error.

@garcia garcia added this to the v3 milestone Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
non-strict parsing bugs related to malformed simfiles that StepMania accepts
Projects
None yet
Development

No branches or pull requests

2 participants