omi
omi copied to clipboard
[Bounty proposal] fix(frankfurter-app): client fallback, non-dict payload guards, and hermetic test suite
Description
A reliability and architecture review of plugins/omi-frankfurter-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-Dict Upstream Payloads:
convert_currencyandget_latest_ratesaccessedpayload.get("rates")without verifying whetherpayloadis a dictionary.- In
list_supported_currencies,currencies.items()was called unconditionally; if Frankfurter returns a non-dict error page or empty list, this raises an unhandledAttributeError. - In
convert_currencyandget_latest_rates, missing or invalid rate values raised unhandledInvalidOperationfrom_format_decimal.
-
Hermetic Test Suite Execution & Checks Manifest Registration:
test_main.pypreviously importedpytestandfastapi.testclient.TestClientat the top level, preventing it from running under standard librarypython3 -S, and was completely unmonitored in.github/checks-manifest.yaml.
Proposed Fix
- Add resilient fallback client handling in
_request_json()and clean resource disposal in lifespan. - Validate upstream JSON payloads are dictionaries before accessing
ratesand iterating.items(). - Guard rate formatters against invalid decimal values.
- Re-architect
test_main.pyinto a 20-test hermetic test suite running with standard libraryunittestin <0.2s without third-party dependencies, with full module isolation. - Register
omi-frankfurter-testsin.github/checks-manifest.yaml.