omi icon indicating copy to clipboard operation
omi copied to clipboard

fix(backend): fall back to /releases/latest when GitHub list returns empty

Open rahulbansal16 opened this issue 7 months ago • 2 comments

Summary

  • macos.omi.me / /v2/desktop/download/latest started serving 404 today because GitHub's GET /repos/.../releases list endpoint went soft-empty (HTTP 200 with []) during a partial GitHub incident, even though releases/latest and /releases/tags/{tag} kept returning the latest desktop build (v0.11.368+11368-macos, isLive: true).
  • _get_live_desktop_releases() saw an empty list, then download_latest_desktop_release() raised 404: No live desktop releases found for platform: macos.
  • Compounding the outage: get_omi_github_releases() cached the empty list for 5 minutes, so the download link would have stayed broken for up to 5 more minutes per pod after GitHub recovered.

Fix

  • When the unfiltered list endpoint returns empty, fall back to GET /repos/{owner}/{repo}/releases/latest for a single-release result. The single-release endpoints stayed up during this incident.
  • Cache empty results for 30s instead of 5 minutes, so we recover quickly from transient list-endpoint outages without hammering the API.
  • Firmware path (called with a tag_filter) is unchanged — the fallback is scoped to the unfiltered desktop call site.

Recording

Test plan

  • [x] Added unit tests in backend/tests/unit/test_firmware_pagination.py:
    • empty list triggers /releases/latest fallback (and caches at 300s)
    • firmware caller (with tag_filter) skips the fallback
    • populated list response skips the fallback
    • fallback exception falls through to empty + 30s TTL
  • [x] Updated existing test_cache_none_triggers_fetch to expect the new 30s negative-cache TTL.
  • [ ] Verify on prod after merge: hit /v2/desktop/download/latest and confirm 200 (HTML landing page that auto-redirects to the DMG).

🤖 Generated with Claude Code

rahulbansal16 avatar Apr 27 '26 19:04 rahulbansal16

https://github.com/user-attachments/assets/7f49b944-2922-45b5-919c-d967c98bc4d9

rahulbansal16 avatar Apr 27 '26 19:04 rahulbansal16

Greptile Summary

Adds a resilience fallback to get_omi_github_releases: when GitHub's list endpoint returns HTTP 200 with [] (as it did during a partial incident), the function now retries via GET /releases/latest before returning. Empty results are cached for 30 s instead of 5 min so recovery is fast once GitHub heals. The fallback is correctly scoped to the unfiltered (desktop) call path and the client reference remains valid inside the async with block.

Confidence Score: 4/5

Safe to merge — the fallback is well-scoped and the only finding is a minor logging improvement.

Only P2 observations; the core logic is correct, the fallback is properly scoped inside the async with block, TTL branching is accurate, and test coverage addresses all four new code paths.

No files require special attention.

Important Files Changed

Filename Overview
backend/routers/firmware.py Adds /releases/latest fallback inside the async with block when the list endpoint returns empty and no tag_filter is set; adjusts cache TTL to 30s for empty results. Logic is correct — fallback only fires for the unfiltered desktop path, client is still in scope, and TTL branching matches expected behaviour.
backend/tests/unit/test_firmware_pagination.py Adds four new tests covering the fallback: empty-list-triggers-fallback (success), tag_filter-skips-fallback, populated-list-skips-fallback, and exception-swallowed. Updates existing TTL assertion from 300 to 30. Coverage is thorough for all code paths introduced in firmware.py.

Sequence Diagram

sequenceDiagram
    participant C as Caller
    participant F as firmware.get_omi_github_releases
    participant Cache as Redis Cache
    participant GL as GitHub /releases (list)
    participant GLatest as GitHub /releases/latest

    C->>F: get_omi_github_releases(cache_key, tag_filter=None)
    F->>Cache: get_generic_cache(cache_key)
    Cache-->>F: None (miss)
    F->>GL: GET /repos/.../releases?per_page=100&page=1
    GL-->>F: 200 []  (soft-empty)
    Note over F: not collected AND not tag_filter → fallback
    F->>GLatest: GET /repos/.../releases/latest
    alt 200 OK
        GLatest-->>F: release object
        F->>Cache: set_generic_cache(key, [release], ttl=300)
        F-->>C: [release]
    else non-200 or exception
        GLatest-->>F: error / exception
        F->>Cache: set_generic_cache(key, [], ttl=30)
        F-->>C: []
    end

Reviews (1): Last reviewed commit: "test(backend): cover /releases/latest fa..." | Re-trigger Greptile

greptile-apps avatar Apr 27 '26 19:04 greptile-apps

ClawSweeper local pilot review

Recommendation: keep open, but do not merge as-is.

What it found:

  • This addresses a real desktop download outage mode.
  • Current main already has overlapping last-known-good release fallback coverage for the common soft-empty GitHub release-list case.
  • A /releases/latest fallback may still be useful, but should be limited to the cold-cache/no-LKG path and should validate that the returned release is a live desktop release.

Related context: current main partially overlaps this via the LKG fallback associated with #7768.

Suggested next step: preserve the current LKG fallback and add /releases/latest only as a validated no-LKG fallback if maintainers want the extra hardening.

Posted from a local report-only ClawSweeper pilot by request; no labels, closes, repairs, or merges were performed.

ThomsenDrake avatar Jun 17 '26 00:06 ThomsenDrake