{"record":{"id":"a821faa274eb928c","repo":"feder-cr/Jobs_Applier_AI_Agent_AIHawk","slug":"vectorstore-not-initialized-run-extract-job-descr","errorCode":null,"errorMessage":"Vectorstore not initialized. Run extract_job_description first.","messagePattern":"Vectorstore not initialized\\. Run extract_job_description first\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/libs/resume_and_cover_builder/llm/llm_job_parser.py","lineNumber":101,"sourceCode":"        # Create the vectorstore using FAISS\n        try:\n            self.vectorstore = FAISS.from_documents(documents=all_splits, embedding=self.llm_embeddings)\n            logger.debug(\"Vectorstore successfully initialized.\")\n        except Exception as e:\n            logger.error(f\"Error during vectorstore creation: {e}\")\n            raise\n\n    def _retrieve_context(self, query: str, top_k: int = 3) -> str:\n        \"\"\"\n        Retrieves the most relevant text fragments using the retriever.\n        Args:\n            query (str): The search query.\n            top_k (int): Number of fragments to retrieve.\n        Returns:\n            str: Concatenated text fragments.\n        \"\"\"\n        if not self.vectorstore:\n            raise ValueError(\"Vectorstore not initialized. Run extract_job_description first.\")\n        \n        retriever = self.vectorstore.as_retriever()\n        retrieved_docs = retriever.get_relevant_documents(query)[:top_k]\n        context = \"\\n\\n\".join(doc.page_content for doc in retrieved_docs)\n        logger.debug(f\"Context retrieved for query '{query}': {context[:200]}...\")  # Log the first 200 characters\n        return context\n    \n    def _extract_information(self, question: str, retrieval_query: str) -> str:\n        \"\"\"\n        Generic method to extract specific information using the retriever and LLM.\n        Args:\n            question (str): The question to ask the LLM for extraction.\n            retrieval_query (str): The query to use for retrieving relevant context.\n        Returns:\n            str: The extracted information.\n        \"\"\"\n        context = self._retrieve_context(retrieval_query)\n        ","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/feder-cr/Jobs_Applier_AI_Agent_AIHawk/blob/79155b52faccfbd19b834680af285eac70dd2df4/src/libs/resume_and_cover_builder/llm/llm_job_parser.py#L83-L119","documentation":"LLMJobParser first ingests the job posting into a vector store (extract_job_description) and then answers extraction queries via similarity search in _retrieve_context. If extraction is attempted before ingestion, self.vectorstore is falsy and the guard raises.","triggerScenarios":"Calling _extract_information (or a public method that uses it) before calling extract_job_description on the same LLMJobParser instance, or when ingestion failed and left vectorstore unset/None.","commonSituations":"Reordering the parse pipeline, reusing a parser instance across jobs without re-ingesting, or ingestion errors (embedding API failure) that were caught upstream leaving the store empty.","solutions":["Call extract_job_description(job_text) on the parser before any information-extraction call.","Check parser.vectorstore is truthy before extracting; re-run ingestion if not.","If ingestion can fail, propagate that error so extraction is never attempted on an un-ingested parser."],"exampleFix":"# before\ninfo = parser._extract_information('salary')\n# after\nparser.extract_job_description(job_text)  # populates vectorstore\ninfo = parser._extract_information('salary')","handlingStrategy":"validation","validationCode":"if not getattr(parser, 'vectorstore', None):\n    parser.extract_job_description(job_text)\ninfo = parser._extract_information('salary')","typeGuard":"def parser_ready(parser) -> bool:\n    return getattr(parser, 'vectorstore', None) is not None","tryCatchPattern":"try:\n    info = parser._extract_information(query)\nexcept ValueError as e:\n    if 'Vectorstore not initialized' in str(e):\n        parser.extract_job_description(job_text)\n        info = parser._extract_information(query)\n    else:\n        raise","preventionTips":["Make ingestion the mandatory first step of every parse job.","Do not reuse a parser instance for a new job posting without re-running extract_job_description."],"tags":["python","vectorstore","state-not-initialized","rag"],"backgroundTag":"operation-before-initialization","analyzedSha":"79155b52faccfbd19b834680af285eac70dd2df4","analyzedAt":"2026-08-28T14:10:26.659Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}