{"record":{"id":"fc93f2efc09b90de","repo":"Radarr/Radarr","slug":"could-not-set-label-to-1-for-torrent-0","errorCode":null,"errorMessage":"Could not set label to {1} for torrent: {0}.","messagePattern":"Could not set label to (.+?) for torrent: (.+?)\\.","errorType":"exception","errorClass":"DownloadClientException","httpStatus":null,"severity":"error","filePath":"src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentProxy.cs","lineNumber":120,"sourceCode":"            }\n            else\n            {\n                response = ExecuteRequest(settings, \"load.raw_start\", args.ToArray());\n            }\n\n            if (response.GetIntResponse() != 0)\n            {\n                throw new DownloadClientException(\"Could not add torrent: {0}.\", fileName);\n            }\n        }\n\n        public void SetTorrentLabel(string hash, string label, RTorrentSettings settings)\n        {\n            var response = ExecuteRequest(settings, \"d.custom1.set\", hash, label);\n\n            if (response.GetStringResponse() != label)\n            {\n                throw new DownloadClientException(\"Could not set label to {1} for torrent: {0}.\", hash, label);\n            }\n        }\n\n        public void PushTorrentUniqueView(string hash, string view, RTorrentSettings settings)\n        {\n            var response = ExecuteRequest(settings, \"d.views.push_back_unique\", hash, view);\n\n            if (response.GetIntResponse() != 0)\n            {\n                throw new DownloadClientException(\"Could not push unique view {0} for torrent: {1}.\", view, hash);\n            }\n        }\n\n        public void RemoveTorrent(string hash, RTorrentSettings settings)\n        {\n            var response = ExecuteRequest(settings, \"d.erase\", hash);\n\n            if (response.GetIntResponse() != 0)","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/Radarr/Radarr/blob/ca451608dc60c6cec754aba8d96bfa30e9468ed5/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentProxy.cs#L102-L138","documentation":"Thrown by RTorrentProxy.SetTorrentLabel when the d.custom1.set command's string response does not equal the label that was set. rTorrent echoes the set value on success; a mismatch means the label was not stored as expected. This is the mechanism Radarr/Sonarr uses to tag torrents with their category/label.","triggerScenarios":"ExecuteRequest(settings, \"d.custom1.set\", hash, label) returns a string via GetStringResponse() that differs from label, triggering the throw with hash and label.","commonSituations":"Special characters or encoding issues in the label that rTorrent normalizes differently; label length limits; rTorrent version returning a transformed value; concurrent modification; the torrent hash does not exist so the set is a no-op returning empty.","solutions":["Simplify the label (alphanumeric, no special characters) to test whether encoding is the cause.","Confirm the torrent hash exists in rTorrent before setting the label (HasHashTorrent).","Check rTorrent logs for why the set value was not echoed back as-is."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Normalize the label and confirm the torrent exists before setting it\nvar safeLabel = new string(label.Where(c => char.IsLetterOrDigit(c) || c == '-' || c == '_').ToArray());\nif (safeLabel != label) throw new InvalidOperationException(\"Label has characters rTorrent may not echo back faithfully.\");\nif (!_proxy.HasHashTorrent(hash, settings)) throw new InvalidOperationException(\"Cannot set label; torrent hash not found.\");","typeGuard":null,"tryCatchPattern":"try { _proxy.SetTorrentLabel(hash, label, settings); }\ncatch (DownloadClientException ex) when (ex.Message.Contains(\"set label\"))\n{\n    _logger.Warn(\"rTorrent did not echo label '\" + label + \"' for \" + hash + \"; it may still be set or unsupported.\");\n}","preventionTips":["Restrict labels to simple characters to avoid echo mismatches.","Confirm the torrent exists before applying metadata commands.","Treat a label echo mismatch as a warning rather than fatal where appropriate."],"tags":["rtorrent","download-client","xmlrpc","configuration","metadata"],"backgroundTag":null,"analyzedSha":"ca451608dc60c6cec754aba8d96bfa30e9468ed5","analyzedAt":"2026-08-13T17:21:54.115Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}