Skip to content

fix: rename self-update command to 'uteke upgrade' - #603

Merged
ajianaz merged 3 commits into
developfrom
fix/self-update-command
Jul 7, 2026
Merged

ajianaz merged 3 commits into
developfrom
fix/self-update-command

Conversation

@ajianaz

@ajianaz ajianaz commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes 5 compilation errors from #601 by renaming the self-update command from uteke update to uteke upgrade.

Problem

Commands::Update already exists as a document partial-update command (uteke doc update <id>, #589). The self-update PR created a naming collision that caused all CI checks to fail.

Changes

File Change
cli.rs Added Commands::Upgrade variant, removed AgingCommands::Update (wrong enum)
commands/mod.rs mod update → mod upgrade, dispatcher uses Commands::Upgrade
commands/upgrade.rs Return type Result<(), Box<dyn Error>> → Result<(), String>, fixed entry.path() Cow bug, all .into() calls

Resolved errors

  • E0599: entry.path() returns Cow<Path>, not Result — removed invalid .map_err()
  • E0277: Err(String).into() type mismatch with Box<dyn Error>
  • E0599: Commands::Update { yes } didn't match existing Commands::Update fields
  • E0308: Match arm type mismatch (Box<dyn Error> vs String)
  • E0004: Non-exhaustive AgingCommands::Update (removed — semantically wrong)

Closes #601, Closes #581

ajianaz added 2 commits July 7, 2026 11:52
Check for latest release on GitHub, compare against installed version,
prompt for confirmation, download with checksum verification, and
atomically replace the running binary.

Features:
- Detects current binary path automatically
- OS/arch detection (linux/darwin, x86_64/aarch64)
- Primary: parse GitHub 302 redirect (no API rate limit)
- Fallback: GitHub REST API
- SHA256 checksum verification from release assets
- Archive path traversal protection (CWE-22)
- Atomic rename replace (safe on POSIX)
- New binary verification before swap
- --yes flag for non-interactive / CI use
- Already-up-to-date detection (skip download)
- Missing dev headers warning for cargo-installed binaries

Closes #581
- Rename Commands::Update → Commands::Upgrade to avoid collision with
  existing document update command (uteke doc update <id>)
- Remove from AgingCommands (semantically wrong — self-update is not aging)
- Change return type from Result<(), Box<dyn Error>> → Result<(), String>
  to match the dispatcher contract
- Fix entry.path() bug: was calling .map_err() on Cow<Path> which is
  not a Result type
- Fix all .into() calls that no longer compile with String error type
- Rename update.rs → upgrade.rs module file
@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

❌ Blocked — critical issues found.

🔴 Error (2)

  • crates/uteke-cli/src/commands/upgrade.rs:231 — In get_latest_version(), the code sends client.head("https://github.com/{REPO}/releases/latest") and then tries to read the location header from the response. reqwest::blocking::Client::new() follows redirects by default, so for GitHub's /releases/latest endpoint this request will usually return the final 200 response without a location header. That makes the primary detection path fail on normal configurations and forces the fallback API call every time.
  • crates/uteke-cli/src/commands/upgrade.rs:190 — The final replacement step uses fs::rename(&temp_new, &current_exe).map_err(|e| format!("Failed to replace binary: {e}"))?;. If that rename fails (for example due to cross-filesystem or permission issues), the function returns immediately without removing temp_new or temp_dir. Earlier failure branches do clean these up, so this path is inconsistent and can leave a stray executable and extracted archive in the filesystem.

Review powered by cora-cli · BYOK · MIT

Upgrade was accidentally placed inside DocCommands enum instead of the
top-level Commands enum. This caused:
- E0599: no variant 'Upgrade' in Commands (dispatcher couldn't find it)
- E0004: non-exhaustive DocCommands::Upgrade (doc handler doesn't handle it)
return Err(format!(
"New binary failed to run: {}",
String::from_utf8_lossy(&output.stderr)
));
("linux", "x86_64") => Ok("x86_64-unknown-linux-gnu".into()),
("linux", "aarch64") => Ok("aarch64-unknown-linux-gnu".into()),
("darwin", "aarch64") => Ok("aarch64-apple-darwin".into()),
("darwin", "x86_64") => {
@ajianaz
ajianaz merged commit b107e0f into develop Jul 7, 2026
8 of 9 checks passed
@ajianaz
ajianaz deleted the fix/self-update-command branch July 7, 2026 05:49
ajianaz added a commit that referenced this pull request Aug 13, 2026
fix: rename self-update command to 'uteke upgrade'
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.

feat: command — self-update with confirmation

2 participants