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

Imported trailing newlines cause IndexError #200

Open
rhartmann opened this issue Feb 5, 2025 · 0 comments
Open

Imported trailing newlines cause IndexError #200

rhartmann opened this issue Feb 5, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@rhartmann
Copy link
Contributor

Suppose you have the following test file with at least two trailing newlines:

# Blame

Test

Import that into the repository by commiting it on the CLI or pulling it from somewhere.

You can view the resulting page, but when trying to show its blame, you get:

  File "/opt/venv/lib/python3.12/site-packages/otterwiki/wiki.py", line 742, in blame
    line = markup_lines[int(row[3]) - 1]
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
IndexError: list index out of range

Wrapping line 742 into try/except like this seems to fix it:

try:
  line = markup_lines[int(row[3]) - 1]
except IndexError as e:
  line = ""

Admittedly, it's a corner case. It does not happen when saving the page from within the wiki where trailing newlines are truncated to a single newline.

@redimp redimp added the bug Something isn't working label Feb 5, 2025
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

2 participants