mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-10-03 20:53:09 +00:00
fix: improve Proxmox API permission error messages
Addresses #379 - Added clearer error messages for common authentication issues: - 403 errors now explain that permissions must be set on the USER (not just the token) in Proxmox GUI - 595 errors indicate authentication failure - 401 errors indicate invalid credentials While the setup script handles this correctly, these messages help users who manually configure permissions.
This commit is contained in:
+13
-2
@@ -262,8 +262,19 @@ func (c *Client) request(ctx context.Context, method, path string, data url.Valu
|
||||
defer resp.Body.Close()
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
|
||||
// Create base error
|
||||
err := fmt.Errorf("API error %d: %s", resp.StatusCode, string(body))
|
||||
// Create base error with helpful guidance for common issues
|
||||
var err error
|
||||
if resp.StatusCode == 403 && c.config.TokenName != "" {
|
||||
// Special case for 403 with API token - this is usually a permission issue
|
||||
err = fmt.Errorf("API error 403 (Forbidden): The API token does not have sufficient permissions. Note: In Proxmox GUI, permissions must be set on the USER (not just the token). Please verify the user '%s@%s' has the required permissions", c.auth.user, c.auth.realm)
|
||||
} else if resp.StatusCode == 595 {
|
||||
// 595 is Proxmox "no ticket" error - usually means authentication failed
|
||||
err = fmt.Errorf("API error 595: Authentication failed - please check your credentials")
|
||||
} else if resp.StatusCode == 401 {
|
||||
err = fmt.Errorf("API error 401 (Unauthorized): Invalid credentials or token")
|
||||
} else {
|
||||
err = fmt.Errorf("API error %d: %s", resp.StatusCode, string(body))
|
||||
}
|
||||
|
||||
// Log auth issues for debugging (595 is Proxmox "no ticket" error)
|
||||
if resp.StatusCode == 595 || resp.StatusCode == 401 || resp.StatusCode == 403 {
|
||||
|
||||
Reference in New Issue
Block a user