{"record":{"id":"03a8c28a1ebeb39d","repo":"AlistGo/alist","slug":"failed-to-delete-qbittorrent-tag","errorCode":null,"errorMessage":"failed to delete qbittorrent tag","messagePattern":"failed to delete qbittorrent tag","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/qbittorrent/client.go","lineNumber":363,"sourceCode":"\t} else {\n\t\tv.Set(\"deleteFiles\", \"false\")\n\t}\n\tresponse, err := c.post(\"/api/v2/torrents/delete\", v)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif response.StatusCode != 200 {\n\t\treturn errors.New(\"failed to delete qbittorrent task\")\n\t}\n\n\tv = url.Values{}\n\tv.Set(\"tags\", \"alist-\"+id)\n\tresponse, err = c.post(\"/api/v2/torrents/deleteTags\", v)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif response.StatusCode != 200 {\n\t\treturn errors.New(\"failed to delete qbittorrent tag\")\n\t}\n\treturn nil\n}\n","sourceCodeStart":345,"sourceCodeEnd":367,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/pkg/qbittorrent/client.go#L345-L367","documentation":"After successfully deleting a torrent, deleting its management tag via POST /api/v2/torrents/deleteTags returned non-200. Only tag cleanup failed; the torrent itself is already gone.","triggerScenarios":"Calling DeleteTorrent when the session lost authorization between the two POSTs, or qBittorrent rejects the deleteTags call for the tag \"alist-<id>\".","commonSituations":"WebUI session expiry mid-delete; qBittorrent restart between calls; harmless leftover tags accumulate if this error is not tolerated.","solutions":["Treat tag-deletion failure as non-fatal: log it and return success for the overall delete (torrent removal already succeeded)","Re-login and retry the deleteTags call once","Periodically clean orphaned alist-* tags in qBittorrent if errors were swallowed"],"exampleFix":"// before\nif response.StatusCode != 200 {\n    return errors.New(\"failed to delete qbittorrent tag\")\n}\n\n// after\nif response.StatusCode != 200 {\n    log.Warnf(\"failed to delete qbittorrent tag %s: status %d\", \"alist-\"+id, response.StatusCode)\n    return nil // torrent deleted; tag cleanup is best-effort\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := c.DeleteTorrent(info, true, id)\nif err != nil && strings.Contains(err.Error(), \"failed to delete qbittorrent tag\") {\n\tlog.Warnf(\"tag cleanup failed for alist-%s; ignoring\", id)\n\treturn nil\n}","preventionTips":["Treat tag cleanup as best-effort once the torrent delete succeeded","Sweep orphaned alist-* tags during periodic maintenance"],"tags":["qbittorrent","cleanup","tags","offline-download"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}