Skip to content

fix(iq_rating): harden AI score array parsing against malformed elements (#14436) - #14682

Merged
kodjima33 merged 2 commits into
BasedHardware:mainfrom
shuoYun114:fix/iq-rating-malformed-score-array-element
Sep 20, 2026
Merged

kodjima33 merged 2 commits into
BasedHardware:mainfrom
shuoYun114:fix/iq-rating-malformed-score-array-element

Conversation

@shuoYun114

@shuoYun114 shuoYun114 commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Failure-Class: none

Review in cubic

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. 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.
  2. 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.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution python labels Sep 19, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5/5: scoped fix for real bug #14436 (non-dict/non-int score elements discard whole batch), test added, CI green, not yet fixed on main.

@shuoYun114
shuoYun114 force-pushed the fix/iq-rating-malformed-score-array-element branch from 3d05c94 to cce6005 Compare September 20, 2026 10:21
@aryanorastar

Copy link
Copy Markdown
Collaborator

#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.

@kodjima33
kodjima33 merged commit 0f8ac95 into BasedHardware:main Sep 20, 2026
34 checks passed
@shuoYun114

Copy link
Copy Markdown
Contributor Author

Hi @aryanorastar @kodjima33,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

positive-signal Automation verified a genuine fix/quality contribution python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants