fix(rank): reject invalid score dimensions before saving results (#488)

This commit is contained in:
Ayobami Adegoke authored and GitHub committed 2026-09-21 08:26:43 +02:00
1 parent 456f2bfdbf
commit 2e8600d69d
3 files changed
+44 -1

No files matched your search

+3 -1
View File
@@ -234,8 +234,10 @@ def overall_score(scores: dict) -> int:
total = 0.0
for dim, weight in WEIGHTS.items():
value = scores.get(dim)
if not isinstance(value, (int, float)):
if isinstance(value, bool) or not isinstance(value, (int, float)):
raise ValueError(f"missing or non-numeric score '{dim}'")
if not 0 <= value <= 100:
raise ValueError(f"score '{dim}' must be finite and between 0 and 100")
total += float(value) * weight
return int(total + 0.5)