Repository navigation
fix(open-meteo): guard forecast sequence bounds and prevent null-unit concatenation TypeError - #13923
Conversation
… concatenation TypeError
1. In get_weather_forecast, accessing daily metric arrays with (daily.get('weather_code') or [None])[index] raised IndexError whenever arrays were empty or shorter than time, failing the entire forecast request. Replaced with safe _safe_item extraction, gracefully falling back to 'n/a' or 'unknown' per field.
2. In get_current_weather, get_weather_forecast, and get_air_quality, unit suffix concatenation like ' ' + units.get(...) raised TypeError if the API or proxy returned null unit values in JSON. Added _format_unit_suffix to safely format non-null string units.
3. If daily['time'] is empty or missing, returns an informative message rather than an empty header.
4. Hardened _format_number to treat booleans as non-numeric ('n/a').
5. Added comprehensive hermetic unit tests in plugins/omi-open-meteo-app/test_main.py and registered open-meteo-app-tests in .github/checks-manifest.yaml.
There was a problem hiding this comment.
All reported issues were addressed across 4 files
You’re at about 96% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact [email protected].
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
Addressed static review feedback in commit e1aee39:
|
|
Reviewed the Open-Meteo hardening fix end to end — the three crash paths it guards against are real on main, the fix is minimal and correct, and I ran the new suite in a clean, network-isolated Python 3.12 container: 8/8 tests pass. Per file:
Thanks for the clean fix and the tests — nice first contribution. Since no CI run has reported on this head yet, leaving final merge sign-off to a human maintainer. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
kodjima33
left a comment
There was a problem hiding this comment.
Real bug confirmed not fixed on main (plugins/omi-open-meteo-app/main.py has no _safe_item/_format_unit_suffix guards; indexing daily arrays out of bounds and concatenating null units both still crash). Root cause stated, 8 new hermetic tests plus existing test_observed_at.py updated, scoped diff. Merging: CI has no failing required checks, not a draft, no abuse signals.
|
Note for bounty payout: Please route the .00 USDC payout to my verified EVM / Base self-custody wallet: |
|
Payout information update:
Thank you! |
Summary
In
plugins/omi-open-meteo-app/main.py:IndexErrorPrevention: Inget_weather_forecast, daily metric lists were accessed via(daily.get("weather_code") or [None])[index]. If any daily array is empty or shorter thandaily["time"], indexing beyond element 0 raises an unhandledIndexError: list index out of range, failing the entire user forecast request. Added_safe_itemhelper to safely index sequences and fall back to"n/a"/"unknown".TypeErrorPrevention: Inget_current_weather,get_weather_forecast, andget_air_quality, expressions such as' ' + units.get(...)crash withTypeError: can only concatenate str (not "NoneType") to strwhen the units payload containsnullvalues in JSON. Implemented_format_unit_suffixto safely handle non-null string units.daily["time"]is empty or missing, returns an explicitNo forecast data available for {place_name}.instead of a blank header.plugins/omi-open-meteo-app/test_main.pywith 8 comprehensive unit tests covering partial daily arrays, null units, and empty time scenarios. Registeredopen-meteo-app-testsin.github/checks-manifest.yaml.Testing
python plugins/omi-open-meteo-app/test_main.py: All 8 tests pass.python plugins/omi-open-meteo-app/test_observed_at.py: All tests pass.git diff --check origin/main: 0 whitespace or formatting warnings.Bounty Payout Destination (EVM / Base USDC):
0xb5aFc89b57Fa8270bB7261348179D28099BEa2a0cc @josancamon19 @kodjima33