docling-project/docling · error · RuntimeError
Invalid binary_data_size value: {parsed_size}
Error message
Invalid binary_data_size value: {parsed_size} What it means
_parse_binary_data_size successfully parsed binary_data_size as an int but the value was negative. A negative byte count is nonsensical and would corrupt the offset arithmetic that slices the binary body, so it is rejected.
Source
Thrown at docling/models/inference_engines/common/kserve_v2_http.py:136
shape = tuple(int(dim) for dim in raw_output.shape)
if raw_output.datatype == "BYTES":
return decode_bytes_tensor(raw_payload, shape)
return np.frombuffer(raw_payload, dtype=np_dtype).reshape(shape)
def _parse_binary_data_size(parameters: Mapping[str, Any] | None) -> int | None:
if not parameters or "binary_data_size" not in parameters:
return None
size = parameters["binary_data_size"]
try:
parsed_size = int(size)
except (TypeError, ValueError) as exc:
raise RuntimeError(f"Invalid binary_data_size value: {size!r}") from exc
if parsed_size < 0:
raise RuntimeError(f"Invalid binary_data_size value: {parsed_size}")
return parsed_size
def _build_binary_request(
*,
inputs: Mapping[str, np.ndarray],
output_names: list[str],
request_parameters: Optional[Mapping[str, Any]],
) -> tuple[Dict[str, str], bytes]:
raw_inputs: list[bytes] = []
payload: Dict[str, Any] = {"inputs": []}
for input_name, tensor in inputs.items():
encoded_tensor, raw_payload = _encode_binary_input_tensor(
name=input_name, tensor=np.asarray(tensor)
)
payload["inputs"].append(encoded_tensor)
raw_inputs.append(raw_payload)
View on GitHub (pinned to 61d76f1ff3)
Solutions
- Inspect the raw response JSON to confirm the negative value and report/fix the server-side computation
- Disable binary transport (use_binary_data=False) until the server is fixed
- If the parameter should be absent, ensure the predictor omits it rather than sending -1
Defensive patterns
Strategy: try-catch
Try / catch
try:
outputs = client.infer(inputs=inputs, output_names=[...])
except RuntimeError as e:
if "Invalid binary_data_size value" in str(e):
raise # server bug: negative byte count; report upstream
raise Prevention
- Ensure predictors omit binary_data_size rather than sending sentinels like -1
- Unit-test server-side size computation with empty and multi-tensor outputs
When it happens
Trigger: A server bug or corrupted response sets binary_data_size to a negative integer (e.g. -1 as a sentinel); integer underflow in a predictor computing payload sizes; tampered/truncated body.
Common situations: Custom predictors using -1 as 'no data' marker instead of omitting the parameter; upstream size calculation bugs after model changes.
Related errors
- Invalid binary_data_size value: {size!r}
- Invalid binary inference response header from {response.url}
- KServe v2 HTTP response did not include enough binary output
- KServe v2 HTTP response included trailing binary output data
- Unsupported numpy dtype for KServe v2 input: {tensor.dtype!s
AI-assisted analysis of docling-project/docling@61d76f1ff3 (2026-08-14).
Data as JSON: /api/errors/b292c4d41a36c599.
Report an issue: GitHub.