tftsr-devops_investigation/INVESTIGATION_FINDINGS.md
Shaun Arman cec962b349
Some checks failed
PR Review Automation / review (pull_request) Has been cancelled
Test / frontend-typecheck (pull_request) Has been cancelled
Test / frontend-tests (pull_request) Has been cancelled
Test / rust-tests (pull_request) Has been cancelled
Test / rust-clippy (pull_request) Has been cancelled
Test / rust-fmt-check (pull_request) Has been cancelled
docs: remove hardcoded 172.0.0.18 references
Replace with generic proxmox-server hostname across all documentation
and code comments.
2026-06-20 21:51:51 -05:00

232 lines
7.1 KiB
Markdown

# Investigation Findings: Remote Add Failure and Updater Errors
## Executive Summary
This investigation identified **two critical issues** in the Tauri application:
1. **Remote add failure**: The `add_proxmox_cluster` command is defined and registered, but the error "Failed to add remote" occurs due to missing error handling in the frontend.
2. **Updater errors**: The updater commands (`check_app_updates`, `get_update_channel`, `set_update_channel`) are **NOT registered** in the Tauri command handler, causing "Command not found" errors.
---
## Issue 1: Remote Add Failure
### Root Cause Analysis
The error "Failed to add remote" occurs in `/src/pages/Proxmox/RemotesPage.tsx` at line 64 and is propagated from the backend `add_proxmox_cluster` command.
#### Code Flow:
1. **Frontend**: `RemotesPage.tsx``handleAddRemote()` (line 55-76)
- Calls `addProxmoxCluster()` from `proxmoxClient.ts`
- Catches error and displays toast notification
2. **Frontend Wrapper**: `proxmoxClient.ts` (line 17-33)
```typescript
export async function addProxmoxCluster(
id: string,
name: string,
clusterType: ClusterType,
connection: { url: string; port: number },
username: string,
password: string
): Promise<ClusterInfo> {
return await invoke<ClusterInfo>("add_proxmox_cluster", {
id, name, cluster_type: clusterType, connection, username, password
});
}
```
3. **Backend Command**: `src-tauri/src/commands/proxmox.rs` (line 35-105)
- **IS registered** in `lib.rs` at line 226
- Stores credentials encrypted in database
- Creates in-memory client pool (unauthenticated)
#### Current Implementation Status:
- ✅ Command is registered: `commands::proxmox::add_proxmox_cluster` (line 226)
- ✅ Command implementation exists in `proxmox.rs`
- ✅ Database migration 034 added `username` column
- ⚠️ Error handling: Frontend catches and displays error, but backend error details may not be descriptive
#### Recent Changes (Commit 87ccbb64):
- Removed live authentication requirement during cluster add
- Credentials are now stored encrypted and used on first API call
- Added `username` column to database schema
---
## Issue 2: Updater Errors
### Root Cause Analysis
The updater commands are **DEFINED** but **NOT REGISTERED** in the Tauri command handler.
#### Missing Commands:
| Command | Location | Status |
|---------|----------|--------|
| `check_app_updates` | `system.rs:498` | ✅ Defined ❌ NOT REGISTERED |
| `get_update_channel` | `system.rs:589` | ✅ Defined ❌ NOT REGISTERED |
| `set_update_channel` | `system.rs:598` | ✅ Defined ❌ NOT REGISTERED |
| `install_app_updates` | `system.rs:579` | ✅ Defined ❌ NOT REGISTERED |
#### Current Command Registration:
**File**: `src-tauri/src/lib.rs` (lines 243-258)
```rust
// System / Settings
commands::system::check_ollama_installed,
commands::system::get_ollama_install_guide,
commands::system::list_ollama_models,
commands::system::pull_ollama_model,
commands::system::delete_ollama_model,
commands::system::detect_hardware,
commands::system::recommend_models,
commands::system::get_settings,
commands::system::update_settings,
commands::system::get_audit_log,
commands::system::get_app_version,
commands::system::set_sudo_password,
commands::system::get_sudo_config_status,
commands::system::test_sudo_password,
commands::system::clear_sudo_password,
```
**MISSING**:
- `commands::system::check_app_updates`
- `commands::system::get_update_channel`
- `commands::system::set_update_channel`
- `commands::system::install_app_updates`
#### Frontend Usage:
**File**: `src/lib/tauriCommands.ts` (lines 652-662)
```typescript
export const checkAppUpdatesCmd = async (): Promise<UpdateCheckResult> =>
invoke<UpdateCheckResult>("check_app_updates");
export const installAppUpdatesCmd = async (): Promise<void> =>
invoke<void>("install_app_updates");
export const getUpdateChannelCmd = async (): Promise<string> =>
invoke<string>("get_update_channel");
export const setUpdateChannelCmd = async (channel: string): Promise<void> =>
invoke<void>("set_update_channel", { channel });
```
**File**: `src/pages/Settings/Updater.tsx` (lines 32, 52)
- Calls `checkAppUpdatesCmd()` and `setUpdateChannelCmd()`
- Both will fail with "Command not found" error
#### Recent Changes (Commit 87ccbb64):
**Before**: Used `tauri-plugin-updater` with `app.updater().check()`
**After**: Direct Gitea HTTP API call (lines 498-576 in `system.rs`)
```rust
let response = client
.get(
"https://gogs.tftsr.com/api/v1/repos/sarman/tftsr-devops_investigation/releases?limit=20",
)
.header("Accept", "application/json")
.send()
.await
```
Key improvements:
- Added update channel filtering (stable vs beta)
- Returns full release info (version, URL, notes)
- Uses `tauri-plugin-opener` for browser launch
---
## Files to Modify
### Fix 1: Updater Commands Registration
**File**: `src-tauri/src/lib.rs`
**Location**: Lines 253-258 (after `get_app_version`)
**Required Addition**:
```rust
commands::system::check_app_updates,
commands::system::install_app_updates,
commands::system::get_update_channel,
commands::system::set_update_channel,
```
### Fix 2: Remote Add Error Handling (Optional Enhancement)
**File**: `src-tauri/src/commands/proxmox.rs`
**Location**: Lines 35-105 (`add_proxmox_cluster`)
**Current Behavior**: Returns generic error from database or encryption failures
**Recommended Enhancement**: Add more descriptive error messages for:
- Invalid URL format
- Duplicate remote name
- Database connection issues
- Encryption failures
---
## Verification Steps
After applying fixes:
1. **Build the application**:
```bash
cd src-tauri
cargo build --release
```
2. **Test updater commands**:
- Navigate to Settings > Updater
- Verify channel selection works
- Verify "Check Now" button works
- Check browser opens on "Download Update"
3. **Test remote add**:
- Navigate to Remotes page
- Click "Add Remote"
- Fill in configuration
- Verify remote is added successfully
- Check database entry in `proxmox_clusters` table
---
## Related Files
| File | Purpose |
|------|---------|
| `src-tauri/src/lib.rs` | Command registration (MISSING updater commands) |
| `src-tauri/src/commands/system.rs` | Updater command implementations |
| `src-tauri/src/commands/proxmox.rs` | Remote/cluster command implementation |
| `src/lib/tauriCommands.ts` | Frontend command wrappers |
| `src/lib/proxmoxClient.ts` | Proxmox API client |
| `src/pages/Settings/Updater.tsx` | Updater UI |
| `src/pages/Proxmox/RemotesPage.tsx` | Remote management UI |
| `src/components/Proxmox/AddRemoteForm.tsx` | Remote add form |
---
## Git History Context
**Commit 87ccbb64** ("fix(proxmox): remove dummy data, fix add-remote, fix updater"):
- Added `list_proxmox_containers` command
- Fixed `add_proxmox_cluster` to store credentials without live auth
- Replaced `tauri-plugin-updater` with direct Gitea API
- Added update channel filtering
- **Issue**: Forgot to register updater commands in `lib.rs`
**Current Branch**: `fix/proxmox-v1.2.1` (commit 758d783e)
**Latest Release**: v1.2.3 (commit 8befa472)