MemPalace/mempalace · error · ValueError
min_chunk_size must be a non-negative int, got {min_chunk_si
Error message
min_chunk_size must be a non-negative int, got {min_chunk_size!r} What it means
Error "min_chunk_size must be a non-negative int, got {min_chunk_size!r}" thrown in MemPalace/mempalace.
Source
Thrown at mempalace/miner.py:682
raise ValueError(f"chunk_size must be a positive int, got {chunk_size!r}")
if not isinstance(chunk_overlap, int) or chunk_overlap < 0:
raise ValueError(f"chunk_overlap must be a non-negative int, got {chunk_overlap!r}")
if chunk_overlap > chunk_size // 2:
# The windowing loop pulls ``end`` back to a boundary only when that
# boundary is past ``start + chunk_size // 2`` (the rfind guards below),
# so a pulled chunk always spans more than ``chunk_size // 2`` chars.
# ``start = end - chunk_overlap`` therefore advances only while
# ``chunk_overlap <= chunk_size // 2``; a larger overlap makes ``start``
# stall or move backward and the loop spins forever on short-line
# content (#2056). The largest safe value is ``chunk_size // 2`` (half,
# rounded down for odd sizes), which still advances and stays allowed.
raise ValueError(
f"chunk_overlap ({chunk_overlap}) must be at most chunk_size // 2 "
f"({chunk_size // 2}); a larger overlap can loop forever on "
f"short-line content (#2056)"
)
if not isinstance(min_chunk_size, int) or min_chunk_size < 0:
raise ValueError(f"min_chunk_size must be a non-negative int, got {min_chunk_size!r}")
# Clean up
content = content.strip()
if not content:
return []
chunks = []
start = 0
chunk_index = 0
# Running newline tallies for the 1-indexed (line_start, line_end)
# locators emitted below. These replace the previous per-chunk
# ``content.count("\n", 0, pos)`` full-prefix rescans, which were O(pos)
# each and O(N*K) over K chunks: a 287 MB / ~433k-chunk file scanned
# ~1.2e14 bytes and ran for days, indistinguishable from a hang (#2054).
# ``start`` and ``end`` each advance monotonically for any
# ``chunk_overlap < chunk_size // 2`` (the default 800/100 config and
# every sane override), so counting only the newly-scanned span is O(N)View on GitHub (pinned to 06cb6987f0)
Solutions
- Pass a non-negative integer min_chunk_size
When it happens
Trigger: Thrown at mempalace/miner.py:682 when the library encounters an invalid state.
Common situations: min_chunk_size was negative or not an int.
AI-assisted analysis of MemPalace/mempalace@06cb6987f0 (2026-08-15).
Data as JSON: /api/errors/486462a405221634.
Report an issue: GitHub.