{"record":{"id":"c79b30dafd49bd82","repo":"run-llama/llama_index","slug":"questions-must-be-1","errorCode":null,"errorMessage":"questions must be >= 1","messagePattern":"questions must be >= 1","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/extractors/metadata_extractors.py","lineNumber":308,"sourceCode":"    )\n    embedding_only: bool = Field(\n        default=True, description=\"Whether to use metadata for emebddings only.\"\n    )\n\n    def __init__(\n        self,\n        llm: Optional[LLM] = None,\n        # TODO: llm_predictor arg is deprecated\n        llm_predictor: Optional[LLM] = None,\n        questions: int = 5,\n        prompt_template: str = DEFAULT_QUESTION_GEN_TMPL,\n        embedding_only: bool = True,\n        num_workers: int = DEFAULT_NUM_WORKERS,\n        **kwargs: Any,\n    ) -> None:\n        \"\"\"Init params.\"\"\"\n        if questions < 1:\n            raise ValueError(\"questions must be >= 1\")\n\n        super().__init__(\n            llm=llm or llm_predictor or Settings.llm,\n            questions=questions,\n            prompt_template=prompt_template,\n            embedding_only=embedding_only,\n            num_workers=num_workers,\n            **kwargs,\n        )\n\n    @classmethod\n    def class_name(cls) -> str:\n        return \"QuestionsAnsweredExtractor\"\n\n    async def _aextract_questions_from_node(self, node: BaseNode) -> Dict[str, str]:\n        \"\"\"Extract questions from a node and return it's metadata dict.\"\"\"\n        if self.is_text_node_only and not isinstance(node, TextNode):\n            return {}","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/extractors/metadata_extractors.py#L290-L326","documentation":"Raised by QuestionsAnsweredExtractor.__init__ when the questions parameter (number of questions the LLM should generate per node, default 5) is less than 1. Like the other metadata extractors, the count is validated eagerly in the constructor because it is interpolated into prompt_template.","triggerScenarios":"Constructing QuestionsAnsweredExtractor(questions=0) from a misconfigured value — config file, environment variable, or computed expression that produces zero/negative.","commonSituations":"Shared config templates reused across extractors where questions defaulted to 0; dynamic question counts derived from document size; refactors that renamed the old questions_per_chunk parameter and lost the value.","solutions":["Pass questions >= 1, e.g. QuestionsAnsweredExtractor() for the default of 5.","Clamp config inputs: questions = max(1, cfg['questions']).","If question metadata is unwanted, drop the extractor from the pipeline."],"exampleFix":"# before\nextractor = QuestionsAnsweredExtractor(questions=cfg[\"questions\"])  # 0\n\n# after\nextractor = QuestionsAnsweredExtractor(questions=max(1, cfg[\"questions\"]))","handlingStrategy":"validation","validationCode":"num_questions = int(config.get(\"questions\", 5))\nif num_questions < 1:\n    raise ValueError(f\"questions must be >= 1, got {num_questions}\")\nextractor = QuestionsAnsweredExtractor(questions=num_questions)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate question counts (>= 1) before construction.","Use Literal/Field(gt=0) constraints in pydantic config models.","Centralize extractor-config validation so all extractors are checked uniformly."],"tags":["validation","configuration","constructor","off-by-one"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}