Skip to content

Fix beta desktop download selection#5602

Merged
kodjima33 merged 1 commit intomainfrom
codex/fix-beta-download-latest-release
Mar 13, 2026
Merged

Fix beta desktop download selection#5602
kodjima33 merged 1 commit intomainfrom
codex/fix-beta-download-latest-release

Conversation

@kodjima33
Copy link
Collaborator

Summary

  • make /v2/desktop/download/latest?channel=beta always return the newest desktop GitHub DMG
  • stop beta download selection from depending on stale release-channel metadata
  • add unit coverage for latest-release beta redirects

Testing

  • pytest backend/tests/unit/test_desktop_updates.py # fails locally: missing httpx dependency in this environment

@kodjima33 kodjima33 merged commit 6e5cf24 into main Mar 13, 2026
2 checks passed
@kodjima33 kodjima33 deleted the codex/fix-beta-download-latest-release branch March 13, 2026 20:00
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 13, 2026

Greptile Summary

This PR fixes the beta desktop download endpoint (/v2/desktop/download/latest?channel=beta) to always return the newest live GitHub release with a DMG asset, regardless of how that release's channel metadata is tagged. Previously, the endpoint only matched releases explicitly marked channel=beta in their release body, which could surface a stale build if the most-recent release was promoted to channel=stable. The stable path and the Sparkle appcast endpoint are unchanged.

Changes:

  • backend/routers/updates.py: Adds a dedicated channel == "beta" early-return path in download_latest_desktop_release that iterates all live releases (sorted newest-first by published_at) and redirects to the first DMG found, bypassing channel-tag filtering.
  • backend/tests/unit/test_desktop_updates.py: Updates test_beta_no_fallback (was expecting 404, now expects 302) to match the new behaviour and adds test_beta_uses_latest_release_even_if_marked_stable to explicitly verify the cross-channel resolution.

Issues found:

  • test_beta_no_fallback was updated to assert the opposite behaviour from its original purpose, but its name was not changed. The name now actively misleads readers about what the test proves.
  • test_beta_no_fallback is the only redirect test in TestDownloadEndpoint that omits follow_redirects=False from AsyncClient, creating an inconsistency with every sibling redirect test.

Confidence Score: 4/5

  • Production logic is correct and safe to merge; minor test quality issues remain.
  • The production code change is small (10 lines), clearly intentional, and correctly implements the stated goal. The logic is covered by two new/updated test cases. The only issues are in the test file: a now-misleading test name and a missing follow_redirects=False flag on one test. Neither affects correctness in the current httpx 0.28 environment, but the misnamed test is a readability/maintenance hazard.
  • backend/tests/unit/test_desktop_updates.py — test_beta_no_fallback test name and missing follow_redirects=False

Important Files Changed

Filename Overview
backend/routers/updates.py Adds a fast-path for channel=beta in download_latest_desktop_release that returns the first live release with a DMG regardless of its channel metadata; stable path unchanged.
backend/tests/unit/test_desktop_updates.py Updates test_beta_no_fallback to expect 302 (was 404) and adds test_beta_uses_latest_release_even_if_marked_stable; the renamed test assertion contradicts its original name and is the only redirect test missing follow_redirects=False.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Router as download_latest_desktop_release
    participant Helper as _get_live_desktop_releases
    participant GitHub as GitHub Releases API

    Client->>Router: GET /v2/desktop/download/latest?channel=beta
    Router->>Helper: _get_live_desktop_releases(platform)
    Helper->>GitHub: get_omi_github_releases(cache_key)
    GitHub-->>Helper: All releases (sorted newest→oldest)
    Note over Helper: Filter: isLive=true, desktop tag, valid version
    Helper-->>Router: Live releases (newest first)

    alt channel == "beta" (NEW PATH)
        loop Iterate all entries (no channel filter)
            Router->>Router: _get_dmg_download_url(entry["release"])
            Router-->>Client: 302 Redirect to DMG (first hit, newest build)
        end
        Router-->>Client: 404 No DMG found (all entries exhausted)
    else channel == "stable"
        loop Filter entries where channel == "stable"
            Router->>Router: _get_dmg_download_url(entry["release"])
            Router-->>Client: 302 Redirect to stable DMG
        end
        Note over Router: Fallback: if no stable, try newest live release
        Router-->>Client: 302 or 404
    end
Loading

Comments Outside Diff (1)

  1. backend/tests/unit/test_desktop_updates.py, line 508-519 (link)

    Test name contradicts the new assertion

    The method is named test_beta_no_fallback, which originally described the old behaviour where a channel=beta request returned 404 when no beta-tagged release existed (i.e., there was no fallback to stable). After this PR the assertion has been flipped to expect a 302 to stable.dmg, meaning the beta endpoint now does resolve to a non-beta release. The test name directly contradicts what the test verifies and will mislead future readers.

    Additionally, this is the only redirect test in TestDownloadEndpoint that does not pass follow_redirects=False to AsyncClient, while tests on lines 476–478, 499–501, and 533–536 all do. Although httpx 0.28 defaults to False, the inconsistency increases the risk of a future httpx upgrade silently masking the 302 assertion if behaviour changes.

    Consider renaming and adding the flag:

Last reviewed commit: c8eeb9c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant