run-llama/llama_index · error · ValueError

Configured node parser does not have chunk size.

Error message

Configured node parser does not have chunk size.

What it means

Settings.chunk_size is a convenience proxy that forwards to Settings.node_parser.chunk_size. If the currently configured node parser has no chunk_size attribute (any parser that is not a chunking splitter, e.g. HierarchicalNodeParser, MarkdownNodeParser, SentenceWindowNodeParser, or a custom NodeParser), reading the property raises this ValueError.

Source

Thrown at llama-index-core/llama_index/core/settings.py:161

            self._node_parser = SentenceSplitter()

        if self._callback_manager is not None:
            self._node_parser.callback_manager = self._callback_manager

        return self._node_parser

    @node_parser.setter
    def node_parser(self, node_parser: NodeParser) -> None:
        """Set the node parser."""
        self._node_parser = node_parser

    @property
    def chunk_size(self) -> int:
        """Get the chunk size."""
        if hasattr(self.node_parser, "chunk_size"):
            return self.node_parser.chunk_size
        else:
            raise ValueError("Configured node parser does not have chunk size.")

    @chunk_size.setter
    def chunk_size(self, chunk_size: int) -> None:
        """Set the chunk size."""
        if hasattr(self.node_parser, "chunk_size"):
            self.node_parser.chunk_size = chunk_size
        else:
            raise ValueError("Configured node parser does not have chunk size.")

    @property
    def chunk_overlap(self) -> int:
        """Get the chunk overlap."""
        if hasattr(self.node_parser, "chunk_overlap"):
            return self.node_parser.chunk_overlap
        else:
            raise ValueError("Configured node parser does not have chunk overlap.")

    @chunk_overlap.setter

View on GitHub (pinned to afd0fef371)

Solutions

  1. Set chunk size on the splitter itself: Settings.node_parser = SentenceSplitter(chunk_size=512, chunk_overlap=50).
  2. If you need Settings.chunk_size, first (re)install a parser that has it: Settings.node_parser = SentenceSplitter.from_defaults().
  3. For hierarchical layouts, configure chunk sizes per level in the node list (e.g. [1024, 512, 128]) instead of via Settings.chunk_size.
  4. Audit custom NodeParser subclasses and expose chunk_size/chunk_overlap attributes if callers rely on the Settings proxy.

Example fix

# before
Settings.node_parser = HierarchicalNodeParser.from_defaults()
print(Settings.chunk_size)  # ValueError

# after
Settings.node_parser = HierarchicalNodeParser.from_defaults(
    chunk_sizes=[1024, 512, 128]
)
# read chunking config from the concrete splitter, not Settings
splitter = SentenceSplitter(chunk_size=512)
print(splitter.chunk_size)
Defensive patterns

Strategy: type-guard

Validate before calling

from llama_index.core import Settings

def settings_chunk_size(default: int | None = None) -> int | None:
    parser = Settings.node_parser
    if hasattr(parser, 'chunk_size'):
        return parser.chunk_size
    return default  # None or an application-level default

Type guard

def parser_has_chunk_size(parser) -> bool:
    return hasattr(parser, 'chunk_size') and isinstance(getattr(parser, 'chunk_size'), int)

Try / catch

try:
    cs = Settings.chunk_size
except ValueError:
    cs = None  # configured parser does not chunk; derive size elsewhere

Prevention

When it happens

Trigger: Reading Settings.chunk_size after assigning Settings.node_parser = HierarchicalNodeParser(...) (or any parser lacking chunk_size), or code that assumes the default SentenceSplitter is still installed. Also raised by library internals that read Settings.chunk_size for defaults.

Common situations: Swapping in a hierarchical or sentence-window ingestion strategy and then expecting Settings.chunk_size to still work; passing chunk_size through Settings while a custom parser is registered; third-party code reading Settings.chunk_size unconditionally.

Related errors


AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15). Data as JSON: /api/errors/85c59de983599e69. Report an issue: GitHub.