run-llama/llama_index · error · ValueError

Texts and metadata_strs must have the same length

Error message

Texts and metadata_strs must have the same length

What it means

Error "Texts and metadata_strs must have the same length" thrown in run-llama/llama_index.

Source

Thrown at llama-index-core/llama_index/core/node_parser/interface.py:263

        doc = getattr(user_init, "__doc__", None)
        if not doc:
            return

        # Patch the generated __init__ that help() will show
        try:
            cls.__init__.__doc__ = doc
        except (AttributeError, TypeError):
            pass

    @abstractmethod
    def split_text_metadata_aware(self, text: str, metadata_str: str) -> List[str]: ...

    def split_texts_metadata_aware(
        self, texts: List[str], metadata_strs: List[str]
    ) -> List[str]:
        if len(texts) != len(metadata_strs):
            raise ValueError("Texts and metadata_strs must have the same length")
        nested_texts = [
            self.split_text_metadata_aware(text, metadata)
            for text, metadata in zip(texts, metadata_strs)
        ]
        return [item for sublist in nested_texts for item in sublist]

    def _get_metadata_str(self, node: BaseNode) -> str:
        """Helper function to get the proper metadata str for splitting."""
        embed_metadata_str = node.get_metadata_str(mode=MetadataMode.EMBED)
        llm_metadata_str = node.get_metadata_str(mode=MetadataMode.LLM)

        # use the longest metadata str for splitting
        if len(embed_metadata_str) > len(llm_metadata_str):
            metadata_str = embed_metadata_str
        else:
            metadata_str = llm_metadata_str

        return metadata_str

View on GitHub (pinned to afd0fef371)

Solutions

  1. Pass texts and metadata_strs lists of equal length.
  2. Pad or trim the metadata_strs list so it matches the number of texts.

When it happens

Trigger: Thrown at llama-index-core/llama_index/core/node_parser/interface.py:263 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/9008c249ff4851df. Report an issue: GitHub.