Validate bulk binary sizes as integral metadata

Reject boolean and floating-point values for int64 bulk binary sizes instead of
silently converting them with int(). Keep integer strings accepted for existing
NVBench JSON compatibility, and add regression coverage for valid and malformed
size payloads.
This commit is contained in:
Oleksandr Pavlyk
2026-06-26 16:40:59 -05:00
parent 0228d46c1d
commit fa1a0253df
2 changed files with 35 additions and 0 deletions

View File

@@ -845,6 +845,16 @@ def extract_binary_filename(summary):
def extract_binary_size(summary):
value = extract_summary_data_value(summary, "size", "int64")
if isinstance(value, bool):
raise ValueError(
f"summary {summary.get('tag', '<unknown>')!r} field 'size' "
f"value {value!r} is not an int64"
)
if isinstance(value, float):
raise ValueError(
f"summary {summary.get('tag', '<unknown>')!r} field 'size' "
f"value {value!r} is not an int64"
)
try:
return int(value)
except (TypeError, ValueError) as exc: