Repository navigation
Conversation
…ed elements (BasedHardware#14436) - Validate that each element in AI scores JSON array is a dictionary - Guard against null or non-integer iq values with safe fallback to 100 - Guard against null or whitespace names - Coerce is_name to boolean - Add comprehensive regression test suite in plugins/iq_rating/test_main.py Failure-Class: none
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks @Aj2280 — the production change here is solid and matches the issue's diagnosis well.
plugins/iq_rating/main.py — verified the new per-element guards in calculate_iq_with_ai(): the isinstance(scores, list) check, the per-element isinstance(score, dict) skip with a warning naming the offending type, name validation (missing / null / non-string / whitespace-only), guarded int() coercion defaulting to 100, and is_name normalization. Bounding the failure to the malformed element instead of letting the outer except Exception discard the whole batch is exactly the right fix, and the 70–160 clamp is preserved. The added .strip() on names is a small real improvement — an AI reply of " Alice " now still matches.
plugins/iq_rating/test_main.py — I ran the suite locally from the repo root (python3 -m unittest plugins.iq_rating.test_main): all 6 tests pass in ~2.5s, and the malformed-element, null / non-integer iq, invalid-name, non-list, and no-API-key paths are all covered. Good hermetic seam (requests.post + OPENAI_API_KEY patched, no network, no secrets).
One blocking gap before merge — both parts mechanical:
-
The suite isn't registered in
.github/checks-manifest.yaml, so it will never run in CI. Issue #14436 explicitly asked for the regression suite to be registered there, and every sibling plugin suite (omi-frankfurter-app,omi-open-meteo-app,omi-linear-app,omi-github-app,omi-google-calendar-app,omi-hacker-news-app) has an entry like:- id: iq-rating-score-parsing-tests command: ["python3", "plugins/iq_rating/test_main.py"] triggers: ["plugins/iq_rating/**", ".github/checks-manifest.yaml"] lanes: [local, "ci"] reason: "a non-object element or non-integer iq in the AI score array must skip only that element, not discard the whole batch's scores"
Without it, a future refactor of this parsing can reintroduce the batch-discard bug with fully green checks — the exact silent failure mode the issue documents.
-
As written, the file doesn't run under that manifest invocation. Manifest entries execute
python3 plugins/iq_rating/test_main.pyfrom the repo root, wheresys.path[0]is the script's own directory —from plugins.iq_rating import mainthen raisesModuleNotFoundError: No module named 'plugins'(reproduced locally; yourpython -m unittestrun worked only because-mputs the repo root onsys.path). That's exactly why the sibling suites (e.g.plugins/omi-hacker-news-app/test_main.py) load the module withimportlib.util.spec_from_file_locationinstead of a package import — switching to that pattern makes the file work both standalone and underpython -m unittest.
Nothing else blocking — the runtime hardening itself is good to go once the suite is actually wired into CI.
Automated maintainer review on behalf of the Omi maintainers; a human maintainer makes the final merge call.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
kodjima33
left a comment
There was a problem hiding this comment.
Real bug fix for #14436, root cause and per-element guards are correct and match the issue. Confirmed the reviewer's blocking gap independently: the new test suite is not registered in .github/checks-manifest.yaml so it won't run in CI, and it uses a package import that would break under the manifest's direct-script invocation (unlike sibling plugin tests, which use importlib.util.spec_from_file_location). Confidence gate doesn't clear on 'proven correct' as submitted — approve only, not merging.
|
Closing. The IQ non-dict score guard is already on main. This head would drop tests main already has. |
|
Hey @Aj2280 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
Summary
Fixes #14436 by hardening AI score array parsing in
plugins/iq_rating/main.py:scoresJSON array is a dictionary to preventAttributeErroron non-dict elements (integers, strings, nulls)iqvalues to 100 without raisingTypeErrororValueErrornameis_nameto booleanplugins/iq_rating/test_main.pycovering all edge casesEvidence
python -m unittest plugins/iq_rating/test_main.py(6 tests in 2.5s, OK)Failure-Class: none