omi
omi copied to clipboard
[Bounty proposal] fix(public-holidays-app): client fallback, null/non-list payload guards, and hermetic test suite
Description
A reliability and architecture review of plugins/omi-public-holidays-app identified several key areas needing hardening:
-
Unmanaged Context HTTP Client Crash:
_request_json()accessedapp.state.http_clientdirectly. If invoked in unmanaged contexts or test environments without lifespan execution, this raised an unhandledAttributeError: 'State' object has no attribute 'http_client'. Added automatic fallback allocation.
-
Fatal Crashes on Non-List Upstream Payloads:
- When Nager.Date returns an error object (e.g.
{"status": 404, "title": "Not Found"}),get_public_holidaysandget_long_weekendsiterated over the dictionary keys as strings, causing_format_holidayand_format_long_weekendto call.get()on strings and crash withAttributeError: 'str' object has no attribute 'get'. - In
list_supported_countries, non-dict elements crashed while extractingcountryCodeandname.
- When Nager.Date returns an error object (e.g.
-
Defensive Formatting:
- Hardened
_format_holiday,_format_long_weekend, and_format_listagainst non-dict, non-list, or missing attributes, providing safe fallback values.
- Hardened
-
Missing Checks Manifest Registration & Hermetic Test Suite:
- The plugin had 0 unit tests and was completely unmonitored in
.github/checks-manifest.yaml.
- The plugin had 0 unit tests and was completely unmonitored in
Proposed Fix
- Add resilient fallback client handling in
_request_json()and clean resource disposal in lifespan. - Validate upstream JSON payloads are lists before slicing and formatting.
- Guard formatters against non-dict items.
- Implement a 26-test hermetic test suite (
test_main.py) running with standard libraryunittestin <0.3s without third-party dependencies. - Register
omi-public-holidays-testsin.github/checks-manifest.yaml.
Closing as already fixed on current main.
Current main public-holidays _request_json has client fallback and get_public_holidays isinstance(list) guards + test_main.py