{"record":{"id":"2601a0599dd90c0c","repo":"run-llama/llama_index","slug":"summaries-must-be-one-of-self-prev-next","errorCode":null,"errorMessage":"summaries must be one of ['self', 'prev', 'next']","messagePattern":"summaries must be one of \\['self', 'prev', 'next'\\]","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/extractors/metadata_extractors.py","lineNumber":395,"sourceCode":"    )\n\n    _self_summary: bool = PrivateAttr()\n    _prev_summary: bool = PrivateAttr()\n    _next_summary: bool = PrivateAttr()\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        summaries: List[str] = [\"self\"],\n        prompt_template: str = DEFAULT_SUMMARY_EXTRACT_TEMPLATE,\n        num_workers: int = DEFAULT_NUM_WORKERS,\n        **kwargs: Any,\n    ):\n        # validation\n        if not all(s in [\"self\", \"prev\", \"next\"] for s in summaries):\n            raise ValueError(\"summaries must be one of ['self', 'prev', 'next']\")\n\n        super().__init__(\n            llm=llm or llm_predictor or Settings.llm,\n            summaries=summaries,\n            prompt_template=prompt_template,\n            num_workers=num_workers,\n            **kwargs,\n        )\n\n        self._self_summary = \"self\" in summaries\n        self._prev_summary = \"prev\" in summaries\n        self._next_summary = \"next\" in summaries\n\n    @classmethod\n    def class_name(cls) -> str:\n        return \"SummaryExtractor\"\n\n    async def _agenerate_node_summary(self, node: BaseNode) -> str:","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/extractors/metadata_extractors.py#L377-L413","documentation":"Raised by SummaryExtractor.__init__ when any entry in the summaries list is not one of 'self', 'prev', 'next'. These flags select which node summaries to generate (the node itself, its predecessor, or its successor) and are later used to build metadata keys like node_summary/prev_section_summary/next_section_summary, so unrecognized values fail fast at construction.","triggerScenarios":"Constructing SummaryExtractor(summaries=['current']) (wrong vocabulary), summaries=['self ','prev'] (stray whitespace), or summaries=[] piped through a bad mapping step; also non-lowercase variants like 'Prev'.","commonSituations":"Config-driven pipelines where users write intuitive names ('previous', 'next_section'); string manipulation (split, strip) introducing whitespace/casing; copying example configs from older or newer docs with different accepted values.","solutions":["Use only 'self', 'prev', 'next': SummaryExtractor(summaries=['self', 'prev', 'next']).","Normalize config input: summaries = [s.strip().lower() for s in cfg['summaries']] and validate against the allowed set before constructing.","Omit the summaries argument entirely if you only want the default ['self']."],"exampleFix":"# before\nextractor = SummaryExtractor(summaries=[\"self\", \"previous\"])\n\n# after\nallowed = {\"self\", \"prev\", \"next\"}\nsummaries = [s.strip().lower() for s in cfg[\"summaries\"]]\nassert set(summaries) <= allowed, f\"allowed: {sorted(allowed)}\"\nextractor = SummaryExtractor(summaries=summaries)","handlingStrategy":"validation","validationCode":"ALLOWED = {\"self\", \"prev\", \"next\"}\nsummaries = [s.strip().lower() for s in config[\"summaries\"]]\ninvalid = set(summaries) - ALLOWED\nif invalid:\n    raise ValueError(f\"Invalid summary modes {invalid}; allowed: {sorted(ALLOWED)}\")\nextractor = SummaryExtractor(summaries=summaries)","typeGuard":"def is_valid_summary_modes(values: list[str]) -> bool:\n    return bool(values) and all(v in {\"self\", \"prev\", \"next\"} for v in values)","tryCatchPattern":null,"preventionTips":["Normalize (strip/lower) and whitelist-check summary modes before construction.","Use pydantic Literal['self','prev','next'] lists in config schemas.","Reject empty/near-empty strings early — they will not match."],"tags":["validation","configuration","enum-value","metadata-extraction"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}