run-llama/llama_index · error · ValueError
Invalid mode: {v}
Error message
Invalid mode: {v} What it means
Error "Invalid mode: {v}" thrown in run-llama/llama_index.
Source
Thrown at llama-index-core/llama_index/core/postprocessor/node.py:175
Args:
docstore (BaseDocumentStore): The document store.
num_nodes (int): The number of nodes to return (default: 1)
mode (str): The mode of the post-processor.
Can be "previous", "next", or "both.
"""
docstore: BaseDocumentStore
num_nodes: int = Field(default=1)
mode: str = Field(default="next")
@field_validator("mode")
@classmethod
def _validate_mode(cls, v: str) -> str:
"""Validate mode."""
if v not in ["next", "previous", "both"]:
raise ValueError(f"Invalid mode: {v}")
return v
@classmethod
def class_name(cls) -> str:
return "PrevNextNodePostprocessor"
def _postprocess_nodes(
self,
nodes: List[NodeWithScore],
query_bundle: Optional[QueryBundle] = None,
) -> List[NodeWithScore]:
"""Postprocess nodes."""
all_nodes: Dict[str, NodeWithScore] = {}
for node in nodes:
all_nodes[node.node.node_id] = node
if self.mode == "next":
all_nodes.update(get_forward_nodes(node, self.num_nodes, self.docstore))
elif self.mode == "previous":View on GitHub (pinned to afd0fef371)
Solutions
- Use a valid mode value for the postprocessor (check the class's allowed modes).
- Correct the mode argument passed to the constructor.
When it happens
Trigger: Thrown at llama-index-core/llama_index/core/postprocessor/node.py:175 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15).
Data as JSON: /api/errors/718f3a86e7d01744.
Report an issue: GitHub.