Radarr/Radarr · error · DownloadClientException

Could not set label to {1} for torrent: {0}.

Error message

Could not set label to {1} for torrent: {0}.

What it means

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.

Source

Thrown at src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentProxy.cs:120

            }
            else
            {
                response = ExecuteRequest(settings, "load.raw_start", args.ToArray());
            }

            if (response.GetIntResponse() != 0)
            {
                throw new DownloadClientException("Could not add torrent: {0}.", fileName);
            }
        }

        public void SetTorrentLabel(string hash, string label, RTorrentSettings settings)
        {
            var response = ExecuteRequest(settings, "d.custom1.set", hash, label);

            if (response.GetStringResponse() != label)
            {
                throw new DownloadClientException("Could not set label to {1} for torrent: {0}.", hash, label);
            }
        }

        public void PushTorrentUniqueView(string hash, string view, RTorrentSettings settings)
        {
            var response = ExecuteRequest(settings, "d.views.push_back_unique", hash, view);

            if (response.GetIntResponse() != 0)
            {
                throw new DownloadClientException("Could not push unique view {0} for torrent: {1}.", view, hash);
            }
        }

        public void RemoveTorrent(string hash, RTorrentSettings settings)
        {
            var response = ExecuteRequest(settings, "d.erase", hash);

            if (response.GetIntResponse() != 0)

View on GitHub (pinned to ca451608dc)

Solutions

  1. Simplify the label (alphanumeric, no special characters) to test whether encoding is the cause.
  2. Confirm the torrent hash exists in rTorrent before setting the label (HasHashTorrent).
  3. Check rTorrent logs for why the set value was not echoed back as-is.
Defensive patterns

Strategy: validation

Validate before calling

// Normalize the label and confirm the torrent exists before setting it
var safeLabel = new string(label.Where(c => char.IsLetterOrDigit(c) || c == '-' || c == '_').ToArray());
if (safeLabel != label) throw new InvalidOperationException("Label has characters rTorrent may not echo back faithfully.");
if (!_proxy.HasHashTorrent(hash, settings)) throw new InvalidOperationException("Cannot set label; torrent hash not found.");

Try / catch

try { _proxy.SetTorrentLabel(hash, label, settings); }
catch (DownloadClientException ex) when (ex.Message.Contains("set label"))
{
    _logger.Warn("rTorrent did not echo label '" + label + "' for " + hash + "; it may still be set or unsupported.");
}

Prevention

When it happens

Trigger: ExecuteRequest(settings, "d.custom1.set", hash, label) returns a string via GetStringResponse() that differs from label, triggering the throw with hash and label.

Common situations: 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.

Related errors


AI-assisted analysis of Radarr/Radarr@ca451608dc (2026-08-13). Data as JSON: /api/errors/fc93f2efc09b90de. Report an issue: GitHub.