Repository navigation
fix(iq_rating): harden AI score array parsing against malformed elements (#14436) - #14682
Conversation
Git-on-my-level
left a comment
There was a problem hiding this comment.
Verified this against issue #14436 — the fix is correct and well scoped. Detail per file:
plugins/iq_rating/main.py — the parse loop in calculate_iq_with_ai() now skips non-dict elements with a logged warning instead of raising into the surrounding except that previously discarded every valid score in the batch; non-string or blank names are skipped; a null/non-numeric iq falls back to 100 rather than crashing int(). Clamping to [70, 160] and the person-matching semantics are unchanged, and the scores-not-a-list case is guarded.
plugins/iq_rating/test_main.py — the hermetic suite (stdlib-only fastapi/requests stubs, mocked requests.post) covers exactly the scenarios from the issue: leading non-object elements, null and non-integer iq values, invalid names, non-list JSON, and the no-API-key fallback. I ran it in a network-isolated container: 6/6 pass on this head, and three of them fail against pre-fix main.py — so these are genuine regression tests, not just a harness that would pass either way. Appreciated.
.github/checks-manifest.yaml — iq-rating-score-parsing-tests is registered with the same id/command/triggers/lanes shape as the existing omi-frankfurter-tests entry, with sensible trigger paths (plugin dir plus the manifest itself).
Two notes for maintainers:
- Duplicate selection: #14518 (opened about a day earlier by a different contributor) fixes the same issue with a byte-identical main.py change; this PR additionally registers the check in the manifest and uses a more isolated test harness. One of the two should be picked so credit lands with the right contributor — both independently arrived at the same correct fix.
- One check (Desktop Swift Static & Test Contracts) was still pending at review time; it is unrelated to this Python-only change and the iOS/Android/backend gates are green.
Nice, focused fix with real regression coverage.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
…ribute in hermetic environments
3d05c94 to
cce6005
Compare
|
#14436 is still broken on origin/main: a non-dict element in the AI score array raises into the batch except and discards every valid score. The per-element isinstance/name/iq guards here are the right shape, tests are hermetic, and iq-rating-score-parsing-tests is registered. Not merge-ready from APPROVED: that stamp is on 3d05c94, not head cce6005. The same production loop is also in open #14518 (changes requested: suite not on the manifest). One of these should land; this is the one that actually runs in CI. Still needs maintainer codeowner review — GitHub APPROVED is not merge. |
Failure-Class: none