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

Crash if an invalid folder is passed (list index out of range) #9

Open
melhindi opened this issue Apr 19, 2023 · 4 comments
Open

Crash if an invalid folder is passed (list index out of range) #9

melhindi opened this issue Apr 19, 2023 · 4 comments

Comments

@melhindi
Copy link

melhindi commented Apr 19, 2023

I just installed papis and papis rofi and tried to run it without doing anything else.
When I open papis rofi and then press Alt-u to browse the librar, I get the following error:

~ papis rofi  
INFO:db:cache:Indexing library, this might take a while...
Traceback (most recent call last):
  File "/usr/bin/papis", line 33, in <module>
    sys.exit(load_entry_point('papis==0.12', 'console_scripts', 'papis')())
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/papis_rofi/main.py", line 218, in main
    return Gui().main(documents)
  File "/usr/lib/python3.10/site-packages/papis_rofi/main.py", line 186, in main
    browse(self.documents[i])
IndexError: list index out of range

This is how my config looks like (default config after installing papis):

[papers]
dir = ~/Documents/papers

[settings]
default-library = papers

It turns out that I have a custom folder with the exact same name that is not a papis library.
The same behavior is observable for an empty folder.
The papis cli tool handles this gracefully, ie., it does not crash.
However, papis-rofi crashes as shown above.
I guess simply a check for a valid papis library is missing here?

@Etn40ff
Copy link
Collaborator

Etn40ff commented Apr 20, 2023

I can reproduce this with my setup so I doubt it is due to your custom folder. I'll have a look at it.

@Etn40ff
Copy link
Collaborator

Etn40ff commented Apr 20, 2023

It looks like the issue is that self.window.select returns [-1] when there are no documents

@Etn40ff
Copy link
Collaborator

Etn40ff commented Apr 21, 2023

This should be fixed in latest master branch. Could you test it?

@melhindi
Copy link
Author

melhindi commented May 3, 2023

I just tried:

  1. Remove my previous package based installation
  2. Create a new tmp folder and a python3 venv
  3. Activate the venv and clone the repository
  4. run pip3 install . inside the repo (this also downloads the papis dependency)
  5. run papis rofi

And can confirm that the program does not crash anymore.
However, it simply quits. In case it is easy to add, it would be great to see an info message, like "No libraries found" or so.
But I am fine with closing the issue since it addresses the previously reported error message.

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

No branches or pull requests

2 participants