Add graceful error handling for label removal operations

Co-authored-by: Mord0reK <135718526+Mord0reK@users.noreply.github.com>
pull/878/head
copilot-swe-agent[bot] 2025-11-16 20:04:14 +07:00
parent 15fbdd8044
commit b55de4a8bf
1 changed files with 10 additions and 1 deletions

@ -359,7 +359,16 @@ func (widget *vikunjaWidget) removeLabelFromTask(taskID int, labelID int) error
if response.StatusCode < 200 || response.StatusCode >= 300 {
body, _ := io.ReadAll(response.Body)
return fmt.Errorf("unexpected status code %d: %s", response.StatusCode, string(body))
bodyStr := string(body)
// If the label doesn't exist or was already removed, that's fine
// We want the label off the task, and it is
if response.StatusCode == 404 || response.StatusCode == 400 {
// Label doesn't exist on task, which is the desired state
return nil
}
return fmt.Errorf("unexpected status code %d: %s", response.StatusCode, bodyStr)
}
return nil