omi icon indicating copy to clipboard operation
omi copied to clipboard

[Bounty proposal] fix(frankfurter-app): client fallback, non-dict payload guards, and hermetic test suite

Open shitobu opened this issue 2 months ago • 0 comments

Description

A reliability and architecture review of plugins/omi-frankfurter-app identified several key areas needing hardening:

  1. Unmanaged Context HTTP Client Crash:

    • _request_json() accessed app.state.http_client directly. If invoked in unmanaged contexts or test environments without lifespan execution, this raised an unhandled AttributeError: 'State' object has no attribute 'http_client'. Added automatic fallback allocation.
  2. Fatal Crashes on Non-Dict Upstream Payloads:

    • convert_currency and get_latest_rates accessed payload.get("rates") without verifying whether payload is 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 unhandled AttributeError.
    • In convert_currency and get_latest_rates, missing or invalid rate values raised unhandled InvalidOperation from _format_decimal.
  3. Hermetic Test Suite Execution & Checks Manifest Registration:

    • test_main.py previously imported pytest and fastapi.testclient.TestClient at the top level, preventing it from running under standard library python3 -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 rates and iterating .items().
  • Guard rate formatters against invalid decimal values.
  • Re-architect test_main.py into a 20-test hermetic test suite running with standard library unittest in <0.2s without third-party dependencies, with full module isolation.
  • Register omi-frankfurter-tests in .github/checks-manifest.yaml.

shitobu avatar Sep 16 '26 00:09 shitobu