docling-project/docling · error · RuntimeError
Invalid binary_data_size value: {size!r}
Error message
Invalid binary_data_size value: {size!r} What it means
_parse_binary_data_size could not coerce the server-supplied outputs[].parameters.binary_data_size to int (raised TypeError/ValueError). The KServe v2 spec requires this parameter to be an integer byte count when a tensor is returned in binary form; a non-numeric value means the server or an intermediary mangled the response.
Source
Thrown at docling/models/inference_engines/common/kserve_v2_http.py:134
f"Supported types: {list(KSERVE_V2_NUMPY_DATATYPES.keys())}"
)
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)View on GitHub (pinned to 61d76f1ff3)
Solutions
- Reproduce with curl and inspect the raw JSON header - check outputs[].parameters.binary_data_size
- Fix the server/predictor to emit an integer byte count, or disable binary responses (use_binary_data=False)
- If a proxy is re-encoding JSON, bypass it for the infer route
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):
# capture response via a debug proxy, then fix the server or disable binary
raise
raise Prevention
- Conformance-test custom servers against the KServe v2 binary extension before pointing clients at them
- Avoid JSON-rewriting proxies on the infer route
- Keep use_binary_data=False against servers whose binary support is unverified
When it happens
Trigger: binary_data_size arrives as 'abc', None, a nested object, or a float-formatted string; a JSON re-serializing proxy converts the int to something odd; a hand-rolled test server sends the wrong shape.
Common situations: Mock/test KServe servers written without honoring the binary_data_size contract; gateways that rewrite parameter maps; version drift in custom predictors.
Related errors
- Invalid binary_data_size value: {parsed_size}
- 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/e587bcca56c714d4.
Report an issue: GitHub.