Sonarr/Sonarr · error · DownloadClientException
Deluge failed to add magnet {magnetLink}
Error message
Deluge failed to add magnet {magnetLink} What it means
Thrown by Deluge.AddFromMagnetLink after _proxy.AddTorrentFromMagnet returns a null/whitespace hash. The Deluge JSON-RPC call 'core.add_torrent_magnet' succeeded at the transport layer but Deluge did not return a valid torrent hash, meaning it refused or silently rejected the magnet. This is a DownloadClientException (hard failure), so Sonarr treats the download attempt as failed rather than transiently retrying.
Source
Thrown at src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs:64
{
_proxy.SetTorrentLabel(downloadClientItem.DownloadId.ToLower(), Settings.TvImportedCategory, Settings);
}
catch (DownloadClientUnavailableException)
{
_logger.Warn("Failed to set torrent post-import label \"{0}\" for {1} in Deluge. Does the label exist?",
Settings.TvImportedCategory,
downloadClientItem.Title);
}
}
}
protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink)
{
var actualHash = _proxy.AddTorrentFromMagnet(magnetLink, Settings);
if (actualHash.IsNullOrWhiteSpace())
{
throw new DownloadClientException("Deluge failed to add magnet " + magnetLink);
}
_proxy.SetTorrentSeedingConfiguration(actualHash, remoteEpisode.SeedConfiguration, Settings);
if (Settings.TvCategory.IsNotNullOrWhiteSpace())
{
_proxy.SetTorrentLabel(actualHash, Settings.TvCategory, Settings);
}
var isRecentEpisode = remoteEpisode.IsRecentEpisode();
if ((isRecentEpisode && Settings.RecentTvPriority == (int)DelugePriority.First) ||
(!isRecentEpisode && Settings.OlderTvPriority == (int)DelugePriority.First))
{
_proxy.MoveTorrentToTopInQueue(actualHash, Settings);
}
return actualHash.ToUpper();View on GitHub (pinned to da2284d7ea)
Solutions
- In Deluge Web UI, verify the magnet actually added; if a duplicate exists, remove the existing torrent and let Sonarr re-grab.
- Check the magnet URI is well-formed (starts with 'magnet:?', contains 'xt=urn:btih:<40-char-hex>').
- Inspect Sonarr logs for the preceding DelugeProxy trace to see the raw JSON-RPC response and confirm whether Deluge returned an error vs. an empty result.
- Restart the Deluge daemon to clear a stuck state, then trigger a re-grab in Sonarr (Interactive Search -> Send).
Example fix
// before
var actualHash = _proxy.AddTorrentFromMagnet(magnetLink, Settings);
if (actualHash.IsNullOrWhiteSpace())
{
throw new DownloadClientException("Deluge failed to add magnet " + magnetLink);
}
// after - surface the underlying Deluge error for diagnosis
var actualHash = _proxy.AddTorrentFromMagnet(magnetLink, Settings);
if (actualHash.IsNullOrWhiteSpace())
{
throw new DownloadClientException($"Deluge returned no hash for magnet {magnetLink}. It may already exist; remove it from Deluge and retry.");
} Defensive patterns
Strategy: validation
Validate before calling
// Validate the magnet before handing it to the download client.
private static readonly Regex MagnetRegex = new(@"^magnet:\?xt=urn:btih:[0-9a-fA-F]{40}(&.*)?$", RegexOptions.Compiled);
if (!MagnetRegex.IsMatch(magnetLink))
{
_logger.Warn("Refusing to send malformed magnet to Deluge: {0}", magnetLink);
return; // or mark the release as failed in the grab pipeline
} Type guard
private static bool IsValidMagnet(string magnet) => !string.IsNullOrWhiteSpace(magnet) && magnet.StartsWith("magnet:?") && magnet.Contains("xt=urn:btih:"); Try / catch
// Callers of AddFromMagnetLink (the download client base) should catch DownloadClientException
// to mark the release failed, and DownloadClientUnavailableException to retry later.
try { _proxy.AddTorrentFromMagnet(magnetLink, Settings); }
catch (DownloadClientException ex) { _logger.Error(ex, "Deluge add failed for magnet"); throw; } Prevention
- Filter malformed magnets at the parser/indexer boundary so they never reach the download client.
- Log the magnet prefix (info_hash only, not the full dn/tracker list) when this throws to diagnose duplicates.
- Treat a null hash from Deluge as 'already present' first - check GetItems() before failing.
When it happens
Trigger: AddFromMagnetLink is invoked with a magnetLink; _proxy.AddTorrentFromMagnet calls 'core.add_torrent_magnet' and the deserialized JsonRpcResponse.Result string is null, empty, or whitespace. Common when the magnet URI is malformed, the info_hash is already present and Deluge returns null, or a Deluge plugin/daemon version returns an empty result on success.
Common situations: Duplicate magnet already in Deluge (some Deluge versions return empty instead of the existing hash); magnet string truncated or missing the btih:xt parameter; Deluge daemon restart mid-grab; mismatched Deluge daemon version that does not support the options payload sent by AddTorrentFromMagnet.
Related errors
- Blackhole does not support magnet links.
- Deluge failed to add torrent {filename}
- error.Message
- Magnet not supported by download client. ({0})
- Unable to connect to Deluge, please check your settings
AI-assisted analysis of Sonarr/Sonarr@da2284d7ea (2026-08-13).
Data as JSON: /api/errors/f2d483535f1053ec.
Report an issue: GitHub.