{"record":{"id":"a1627facd7011c23","repo":"aosabook/500lines","slug":"s-index-query-grep-index-dir","errorCode":null,"errorMessage":"%s (index|query|grep) index_dir ...","messagePattern":"(.+?) \\(index\\|query\\|grep\\) index_dir \\.\\.\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"incomplete/search-engine/index.py","lineNumber":260,"sourceCode":"        except Exception:          # The file might e.g. no longer exist.\n            traceback.print_exc()\ndef main(argv):\n    # Eliminate the most common English words from queries and indices.\n    stopwords = 'the of and to a in it is was that i for on you he be'.split()\n\n    if argv[1] == 'index':\n        build_index(index_path=Path(argv[2]), corpus_path=Path(argv[3]),\n                    postings_filters=[discard_long_nonsense_words_filter,\n                                      make_stopwords_filter(stopwords),\n                                      case_insensitive_filter])\n    elif argv[1] == 'query':\n        search_ui(Path(argv[2]), [term for term in argv[3:]\n                                  if term not in stopwords])\n    elif argv[1] == 'grep':\n        grep(Path(argv[2]), [term for term in argv[3:]\n                             if term not in stopwords])\n    else:\n        raise Exception(\"%s (index|query|grep) index_dir ...\" % (argv[0]))\n\nif __name__ == '__main__':\n    main(sys.argv)\n","sourceCodeStart":242,"sourceCodeEnd":264,"githubUrl":"https://github.com/aosabook/500lines/blob/fba689d101eb5600f5c8f4d7fd79912498e950e2/incomplete/search-engine/index.py#L242-L264","documentation":"Error \"%s (index|query|grep) index_dir ...\" thrown in aosabook/500lines.","triggerScenarios":"Thrown at incomplete/search-engine/index.py:260 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Invoke the script with one of the supported subcommands: index, query, or grep.","Provide the index_dir argument after the subcommand.","Check sys.argv handling if wrapping this script so the subcommand is argv[1]."],"exampleFix":"python index.py index my_index_dir/  # or: python index.py query my_index_dir/ term1 term2","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fba689d101eb5600f5c8f4d7fd79912498e950e2","analyzedAt":"2026-08-13T06:26:32.792Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}