{"record":{"id":"37c1cc74a9e385ee","repo":"feder-cr/Jobs_Applier_AI_Agent_AIHawk","slug":"no-numbers-found-in-the-string","errorCode":null,"errorMessage":"No numbers found in the string","messagePattern":"No numbers found in the string","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"src/libs/llm_manager.py","lineNumber":647,"sourceCode":"        try:\n            output = self.extract_number_from_string(output_str)\n            logger.debug(f\"Extracted number: {output}\")\n        except ValueError:\n            logger.warning(\n                f\"Failed to extract number, using default experience: {default_experience}\"\n            )\n            output = default_experience\n        return output\n\n    def extract_number_from_string(self, output_str):\n        logger.debug(f\"Extracting number from string: {output_str}\")\n        numbers = re.findall(r\"\\d+\", output_str)\n        if numbers:\n            logger.debug(f\"Numbers found: {numbers}\")\n            return str(numbers[0])\n        else:\n            logger.error(\"No numbers found in the string\")\n            raise ValueError(\"No numbers found in the string\")\n\n    def answer_question_from_options(self, question: str, options: list[str]) -> str:\n        logger.debug(f\"Answering question from options: {question}\")\n        func_template = self._preprocess_template_string(prompts.options_template)\n        prompt = ChatPromptTemplate.from_template(func_template)\n        chain = prompt | self.llm_cheap | StrOutputParser()\n        raw_output_str = chain.invoke(\n            {\n                RESUME: self.resume,\n                JOB_APPLICATION_PROFILE: self.job_application_profile,\n                QUESTION: question,\n                OPTIONS: options,\n            }\n        )\n        output_str = self._clean_llm_output(raw_output_str)\n        logger.debug(f\"Raw output for options question: {output_str}\")\n        best_option = self.find_best_match(output_str, options)\n        logger.debug(f\"Best option determined: {best_option}\")","sourceCodeStart":629,"sourceCodeEnd":665,"githubUrl":"https://github.com/feder-cr/Jobs_Applier_AI_Agent_AIHawk/blob/79155b52faccfbd19b834680af285eac70dd2df4/src/libs/llm_manager.py#L629-L665","documentation":"extract_number_from_string pulls all digit runs out of the LLM's answer with re.findall(r'\\d+'). If the model answered a numeric question with no digits at all (e.g. 'N/A' or prose), the function raises ValueError because it cannot return a number.","triggerScenarios":"answer_question_numeric invokes the LLM for a numeric field (years of experience, salary) and the reply contains no digits, so numbers is empty and the error is raised.","commonSituations":"LLM refusing or hedging on numeric questions ('I prefer not to say'), non-English digit formats being unlikely but possible (e.g. spelled-out numbers), or a weak/cheap model ignoring the instruction to answer with a number.","solutions":["Retry the numeric question: instruct the model to answer with digits only; often the second attempt works.","Use a stronger model or lower temperature for the numeric chain.","Wrap the call and default to '0' or skip the question when the model gives no numeric answer."],"exampleFix":"# before\nval = llm_manager.extract_number_from_string(ans)\n# after\ntry:\n    val = llm_manager.extract_number_from_string(ans)\nexcept ValueError:\n    val = '0'  # or re-invoke the numeric chain with a digits-only instruction","handlingStrategy":"fallback","validationCode":"import re\nif not re.search(r'\\d', llm_answer):\n    llm_answer = '0'  # or re-prompt with 'answer with digits only'","typeGuard":"def contains_digit(s: str) -> bool:\n    return bool(re.search(r'\\d', s))","tryCatchPattern":"try:\n    val = llm_manager.extract_number_from_string(ans)\nexcept ValueError:\n    val = '0'  # or retry the numeric chain once","preventionTips":["Prompt numeric questions with 'respond with only a number'.","Treat a no-digit answer as a skip/default rather than a crash in form-filling loops."],"tags":["python","llm","regex","numeric-parsing"],"backgroundTag":"llm-output-parsing-failed","analyzedSha":"79155b52faccfbd19b834680af285eac70dd2df4","analyzedAt":"2026-08-28T14:10:26.659Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}