fix(rank): report malformed scoring results in apply instead of a traceback (#635)

* fix(rank): report malformed scoring results in apply instead of a traceback

A result that is not an object, a non-string key or a non-object scores value
raised AttributeError/TypeError and discarded the batch. They now become
errors rows and valid results in the same file still apply.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* changelog: place the #635 entry under [Unreleased]

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Mads Lorentzen <madslorentzen_17@hotmail.com>
This commit is contained in:
authored and GitHub committed 2026-10-19 19:31:34 +02:00
1 parent 3c97e7bc93
commit 9b24a8a123
3 files changed
+40 -1

No files matched your search

+6 -1
View File
@@ -273,6 +273,8 @@ def cmd_sweep(args) -> int:
def overall_score(scores: dict) -> int:
if not isinstance(scores, dict):
raise ValueError("scores must be an object")
total = 0.0
for dim, weight in WEIGHTS.items():
value = scores.get(dim)
@@ -306,8 +308,11 @@ def cmd_apply(args) -> int:
rows, expired, unreachable, gave_up, errors = [], [], [], [], []
for result in results:
if not isinstance(result, dict):
errors.append({"key": None, "error": "result is not an object"})
continue
key = result.get("key")
entry = seen.get(key)
entry = seen.get(key) if isinstance(key, str) else None
if entry is None:
errors.append({"key": key, "error": "no such key in seen_jobs.json"})
continue