Skip to content

fix(upgrade): make 302-redirect primary path actually work for latest-release resolution - #1308

Merged
ajianaz merged 1 commit into
developfrom
fix/upgrade-redirect-follow
Oct 5, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/upgrade-redirect-follow

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

What

Fix get_latest_version() in both uteke upgrade (crates/uteke-cli/src/commands/upgrade.rs) and the startup update check (crates/uteke-core/src/update_check.rs):

  • Disable redirect following on the HEAD probe to https://github.com/codecoradev/uteke/releases/latest (Policy::none()), so the 302 location header carrying the latest tag is actually observable.
  • Validate the tag extracted from the redirect location (v-prefix, numeric major.minor.patch, optional pre-release suffix; query strings stripped) via parse_tag_from_location() + is_valid_version_tag().
  • Harden the GitHub API fallback: Accept: application/vnd.github+json, explicit error on 403/429 (rate limit exceeded ... set GITHUB_TOKEN), and tag_name must pass the same tag validation.
  • Add unit tests for tag parsing/validation in both crates.

Closes #1307.

Why

reqwest follows redirects by default (Policy::limited(10)), so the "primary" HEAD probe landed on the tag page with HTTP 200 and no location header — the primary path was dead code. Every invocation fell through to the unauthenticated api.github.com fallback, capped at 60 req/h per IP. When that budget is exhausted, uteke upgrade and the startup update banner fail with Failed to determine latest version even though the release is reachable. Observed live on 2026-10-05 from a client on 0.18.1.

Evidence (verified live):

  • curl -I .../releases/latest → HTTP/2 302, location: https://github.com/codecoradev/uteke/releases/tag/v0.19.0
  • HEAD with redirects followed (what reqwest was doing) → 200, location: None
  • After this fix the probe resolves v0.19.0 from the 302 alone — zero API calls, immune to rate limiting.

Testing

  • cargo clippy -p uteke-core -p uteke-cli --all-features -- -D warnings — clean
  • cargo test -p uteke-core update_check — 11 passed (6 new)
  • cargo test -p uteke-cli upgrade:: — 5 passed (3 new)
  • Live E2E: debug binary from this branch runs uteke upgrade -y → [INFO] Already up to date (0.19.0) in 0.35s (version resolved via the 302, no API call)
  • cora pre-commit review passed

…-release resolution

reqwest follows redirects by default, so the HEAD probe to
/releases/latest landed on the tag page (200, no location header)
and every invocation fell through to the unauthenticated GitHub
API fallback (60 req/h per IP). Under rate limiting users got
'Failed to determine latest version' from uteke upgrade and the
startup update check (#1307).

Disable redirect following for the probe so the location header
is observable, validate the extracted tag (v-prefix, numeric
major.minor.patch, optional pre-release suffix, query strings
stripped), and give the API fallback an explicit rate-limit error
message instead of a generic one.
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

🔍 Cora AI Code Review

⚠️ Review could not complete. LLM API error after retries: Unknown error — check workflow logs


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 2ad9e5c into develop Oct 5, 2026
16 checks passed
@ajianaz
ajianaz deleted the fix/upgrade-redirect-follow branch October 5, 2026 02:54
ajianaz added a commit that referenced this pull request Oct 5, 2026
* chore(release): v0.19.1 - version bump, changelog, docs sync

- Workspace + internal dependency versions 0.19.0 -> 0.19.1 (Cargo.lock synced)
- CHANGELOG: [0.19.1] entry - upgrade-path reliability (#1307 via #1308/#1309/#1310),
  plain /remember explicit-type fix (#1303), committed Hermes plugin package (#1301)
- Bundled uteke-memory skill + .agents canonical copy bumped in lockstep
- README/README.id current-version line synced

* chore(release): regenerate core-contract.json for 0.19.1

docgen embeds the workspace version; the API Docs Fresh gate caught
the stale generated artifact.

---------

Co-authored-by: ajianaz <[email protected]>
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.

fix: uteke upgrade fails with "Failed to determine latest version" when GitHub API is rate-limited (redirect primary path is dead code)

1 participant