headroomlabs-ai/headroom · error · ValueError
ccr_originals list length {len(ccr_originals)} does not matc
Error message
ccr_originals list length {len(ccr_originals)} does not match contents length {n} What it means
Raised by the batched Kompress path when `ccr_originals` (the un-tag-protected original texts that CCR stores instead of the possibly tag-wrapped `contents` entries) is supplied as a list whose length differs from `len(contents)`. Like the target_ratio check, it enforces a strict per-text alignment before processing starts.
Source
Thrown at headroom/transforms/kompress_compressor.py:1862
return []
t_deadline = time.perf_counter() if _deadline_started_at is None else _deadline_started_at
# Normalize target_ratio to a per-text list
if isinstance(target_ratio, list):
if len(target_ratio) != n:
raise ValueError(
f"target_ratio list length {len(target_ratio)} does not match "
f"contents length {n}"
)
ratios: list[float | None] = list(target_ratio)
else:
ratios = [target_ratio] * n
# Normalize ccr_originals to a per-text list (CCR stores these instead of
# the possibly tag-protected ``contents`` entries; see ``compress``).
if ccr_originals is not None:
if len(ccr_originals) != n:
raise ValueError(
f"ccr_originals list length {len(ccr_originals)} does not match "
f"contents length {n}"
)
ccr_sources: list[str | None] = list(ccr_originals)
else:
ccr_sources = [None] * n
if getattr(self, "_degraded_reason", None) is not None:
return [self._passthrough(c, len(c.split())) for c in contents]
# Fast path: on backends where batch-dim parallelism does NOT help
# (ONNX CPU, PyTorch CPU), fall back to sequential `compress()`
# internally. This keeps the public API consistent while avoiding the
# per-item slowdown measured on ONNX CPU (~0.7-0.9x vs sequential).
# GPU users still benefit from the batched forward pass below.
if self._should_use_sequential_fallback():
return [
self.compress(View on GitHub (pinned to 322425c43b)
Solutions
- Align the lists: `ccr_originals` must have exactly `len(contents)` entries, positionally matching each content
- Derive both lists in the same loop/comprehension over your source records so filtering or reordering always applies to both
- If no CCR originals apply, pass `ccr_originals=None` (the default) rather than an empty or stub list
Example fix
# before results = kompress.compress_batch(contents, ccr_originals=originals) # len mismatch # after pairs = [(c, o) for c, o in zip(contents, originals) if keep(c)] results = kompress.compress_batch([c for c, _ in pairs], ccr_originals=[o for _, o in pairs])
Defensive patterns
Strategy: validation
Validate before calling
def check_ccr_alignment(contents: list[str], ccr_originals) -> None:
if ccr_originals is not None and len(ccr_originals) != len(contents):
raise ValueError(
f"ccr_originals has {len(ccr_originals)} entries for "
f"{len(contents)} contents"
)
check_ccr_alignment(contents, ccr_originals)
results = kompress.compress_batch(contents, ccr_originals=ccr_originals) Type guard
def ccr_aligned(contents: list[str], ccr) -> bool:
return ccr is None or len(ccr) == len(contents) Try / catch
try:
results = kompress.compress_batch(contents, ccr_originals=ccr_originals)
except ValueError as e:
if "ccr_originals list length" in str(e):
results = kompress.compress_batch(contents) # omit originals if truly optional
else:
raise Prevention
- Store (content, ccr_original) as paired tuples/objects so the lists cannot drift
- Apply the same filter/map operations to both lists, once, in one place
- Pass ccr_originals=None when the batch carries no tag-protected entries
When it happens
Trigger: Calling the batched compress API with `ccr_originals=[...]` where the list was built for a different number of texts than `contents` — e.g. contents were split, deduplicated, or extended after the originals list was captured.
Common situations: CCR/tag-protected pipelines where the caller keeps originals in a separate list and mutates `contents` (appending system messages, filtering empties) without applying the same operation to `ccr_originals`; or copying an example that omitted `ccr_originals` semantics and supplying a single-element list.
Related errors
- target_ratio list length {len(target_ratio)} does not match
- Model '{model}' does not have batch output pricing
- Spreadsheet not found: {p}
- Unsupported spreadsheet format '{suffix}'. Supported: .xlsx,
- token_url is required
AI-assisted analysis of headroomlabs-ai/headroom@322425c43b (2026-08-15).
Data as JSON: /api/errors/ff3f6a321ac37ec6.
Report an issue: GitHub.