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

kb grep "IndexError: list index out of range" #83

Closed
ArchWizard56 opened this issue Mar 30, 2021 · 9 comments · Fixed by #89
Closed

kb grep "IndexError: list index out of range" #83

ArchWizard56 opened this issue Mar 30, 2021 · 9 comments · Fixed by #89

Comments

@ArchWizard56
Copy link
Contributor

Hi! It's me again. I've been working on migrating my notes into kb, and I ran across this error. I'm planning on looking into it a bit, but I wanted to open the issue first.

Expected Behavior

kb ought to display a list of artifacts containing the word, as shown in https://github.com/gnebbia/kb#grep-through-the-knowledge-base

Actual Behavior

kb throws an IndexError. This only seems to occur if the grep successfully matches an artifact. Nothing seems to change if I use the -v flag. It works if I use the -m flag to show the matching lines instead of the artifacts.

Ghostbin with full error: https://ghostbin.co/paste/tyqqos

Steps to Reproduce the Problem

  1. Run kb grep with any word that exists in the knowledge base.

Specifications

  • Version: kb-git from the AUR.
  • Platform: Arch Linux
@xscode-auto-reply
Copy link

Thanks for opening a new issue. The team has been notified and will review it as soon as possible.
For urgent issues and priority support, visit https://xscode.com/gnebbia/kb

@gnebbia
Copy link
Owner

gnebbia commented Mar 30, 2021

Dear Sir, I am unable to reproduce the error, can we try to isolate the issue by being more specific about when this throws an exception?

@hexiyou
Copy link

hexiyou commented May 10, 2021

I had the same problem on Cygwin:
image

@gnebbia
Copy link
Owner

gnebbia commented May 10, 2021

Dear Sir, this looks a lot like an older version bug, could you try to uninstall kb and try to re-install the latest version?
Thanks a lot

@gnebbia
Copy link
Owner

gnebbia commented May 11, 2021

Can you let me know if the bug persists on the latest version?

@hexiyou
Copy link

hexiyou commented May 12, 2021

Can you let me know if the bug persists on the latest version?

I already uninstall local version and reinstall from github repository,then i got the same problem.

image


image

@gnebbia
Copy link
Owner

gnebbia commented May 12, 2021

How can i reproduce this? Could you send me some articles from your knowledge base? so that I can inspect them? Probaby related to some UTF-8 char? Did you try deleting your knowledge base and trying to import it again?

You can do something like:
kb add ./myelectornicsstuff/* --category "electronics"
kb add ./cheatsheet/* --category "cheatsheet"
kb add ./protocol/* --category "protocol"
kb add ./config/* --category "config"

To quickly reimport your artcles from text files.
Could you do that test for me?
Because I am not able to reproduce the issue.
Thanks a lot!

@gnebbia
Copy link
Owner

gnebbia commented May 15, 2021

Can you let me know if the bug persists on the latest version?

I already uninstall local version and reinstall from github repository,then i got the same problem.

image

image

Ok, I think I was able to track the issue. I think that updating kb was not enough since this is related to how kb used to store in previous versions artifacts.

Hence, I htink you should basically delete your knowledge base and re-import it.

Unluckily these were issues of previous versions of kb on how data was stored. These issues are fixed with the latest version.

@prokaryont
Copy link

Hi,

i found that the problem (also?) occurs when the title of an artifact contains spaces. Reproducing the error:

kb add -t 'win style name' -b win
kb grep win

01_space_title_error

The cause seems that get_filename_parts_wo_prefix() parses the title of the artifacts incorrectly.

02_incorrectly_parsed_title

Instead of the expected two element tuple of the form [(category, title)], the returned list contains a tuple ('default', 'win', 'style', 'name'). Later, when results are fetches with db_get_artifacts_by_filter(), the category parameter is default/win/style. The call returns an empty list and when the result is indexed the IndexError is raised.

04_incorrect_category_parameter

Quick fix for the users until the issue is resolved: remove spaces/backslashes from your artifacts' titles.

For parsing the path correctly, the pathlib module might help. I'm not sure why backslashes are removed. Is this done to ensure windows compatibility?

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 a pull request may close this issue.

4 participants