{"record":{"id":"85c59de983599e69","repo":"run-llama/llama_index","slug":"configured-node-parser-does-not-have-chunk-size","errorCode":null,"errorMessage":"Configured node parser does not have chunk size.","messagePattern":"Configured node parser does not have chunk size\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/settings.py","lineNumber":161,"sourceCode":"            self._node_parser = SentenceSplitter()\n\n        if self._callback_manager is not None:\n            self._node_parser.callback_manager = self._callback_manager\n\n        return self._node_parser\n\n    @node_parser.setter\n    def node_parser(self, node_parser: NodeParser) -> None:\n        \"\"\"Set the node parser.\"\"\"\n        self._node_parser = node_parser\n\n    @property\n    def chunk_size(self) -> int:\n        \"\"\"Get the chunk size.\"\"\"\n        if hasattr(self.node_parser, \"chunk_size\"):\n            return self.node_parser.chunk_size\n        else:\n            raise ValueError(\"Configured node parser does not have chunk size.\")\n\n    @chunk_size.setter\n    def chunk_size(self, chunk_size: int) -> None:\n        \"\"\"Set the chunk size.\"\"\"\n        if hasattr(self.node_parser, \"chunk_size\"):\n            self.node_parser.chunk_size = chunk_size\n        else:\n            raise ValueError(\"Configured node parser does not have chunk size.\")\n\n    @property\n    def chunk_overlap(self) -> int:\n        \"\"\"Get the chunk overlap.\"\"\"\n        if hasattr(self.node_parser, \"chunk_overlap\"):\n            return self.node_parser.chunk_overlap\n        else:\n            raise ValueError(\"Configured node parser does not have chunk overlap.\")\n\n    @chunk_overlap.setter","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/settings.py#L143-L179","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set chunk size on the splitter itself: Settings.node_parser = SentenceSplitter(chunk_size=512, chunk_overlap=50).","If you need Settings.chunk_size, first (re)install a parser that has it: Settings.node_parser = SentenceSplitter.from_defaults().","For hierarchical layouts, configure chunk sizes per level in the node list (e.g. [1024, 512, 128]) instead of via Settings.chunk_size.","Audit custom NodeParser subclasses and expose chunk_size/chunk_overlap attributes if callers rely on the Settings proxy."],"exampleFix":"# before\nSettings.node_parser = HierarchicalNodeParser.from_defaults()\nprint(Settings.chunk_size)  # ValueError\n\n# after\nSettings.node_parser = HierarchicalNodeParser.from_defaults(\n    chunk_sizes=[1024, 512, 128]\n)\n# read chunking config from the concrete splitter, not Settings\nsplitter = SentenceSplitter(chunk_size=512)\nprint(splitter.chunk_size)","handlingStrategy":"type-guard","validationCode":"from llama_index.core import Settings\n\ndef settings_chunk_size(default: int | None = None) -> int | None:\n    parser = Settings.node_parser\n    if hasattr(parser, 'chunk_size'):\n        return parser.chunk_size\n    return default  # None or an application-level default","typeGuard":"def parser_has_chunk_size(parser) -> bool:\n    return hasattr(parser, 'chunk_size') and isinstance(getattr(parser, 'chunk_size'), int)","tryCatchPattern":"try:\n    cs = Settings.chunk_size\nexcept ValueError:\n    cs = None  # configured parser does not chunk; derive size elsewhere","preventionTips":["Read chunk parameters from the concrete splitter instance you constructed, not from Settings.","After assigning Settings.node_parser, assert hasattr(parser, 'chunk_size') if downstream code relies on Settings.chunk_size.","Keep chunking configuration and parser assignment in one setup location."],"tags":["settings","node-parser","chunking","configuration","llama-index"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}