From d3e06eba2f187fa79826f51ab573c682d1c24c72 Mon Sep 17 00:00:00 2001 From: "jinzheng.architect" Date: Fri, 16 Oct 2026 13:23:38 +0800 Subject: [PATCH] Say when a downloader sent no response qBittorrent's login and every Transmission request reported a transport failure as a bare "login failed" / "request failed". When a WebUI was restarting behind an SSH tunnel, that read like rejected credentials and invited retries toward qBittorrent's failed-login ban. Keep the old text as a prefix and add that nothing answered, still without echoing the underlying error or the URL. Also record the first credentialed M-Team smoke test (status, account, search, UTC+8 times) and note that the website's detail page calls a view-counting endpoint a future adapter should not send. Co-Authored-By: Claude Opus 5.5 --- docs/MTEAM_ADAPTER.md | 14 ++++++++++---- docs/guide/downloader.md | 6 ++++++ internal/downloader/qbittorrent/adapter.go | 4 +++- internal/downloader/qbittorrent/adapter_test.go | 7 +++++-- internal/downloader/transmission/adapter.go | 2 +- internal/downloader/transmission/adapter_test.go | 3 +++ 6 files changed, 28 insertions(+), 8 deletions(-) diff --git a/docs/MTEAM_ADAPTER.md b/docs/MTEAM_ADAPTER.md index d89d1f7..05b6dba 100644 --- a/docs/MTEAM_ADAPTER.md +++ b/docs/MTEAM_ADAPTER.md @@ -12,9 +12,12 @@ read capabilities: - torrent search (`site search`). Torrent detail and metafile download are not implemented yet; see -[Not supported yet](#not-supported-yet). The adapter has not had a credentialed -live smoke test in this repository; its tests use synthetic responses shaped -after the public API. +[Not supported yet](#not-supported-yet). The three reads were smoke-tested live +on 2026-10-16 with a newly created API key: `site status` reported +`authenticated`, `site account` read the profile, and `site search` returned +results in both table and JSON output. A creation time the API returned for that +key matched UTC+8, confirming how [times](#results) are read. The unit tests use +synthetic responses shaped after the public API. ## Getting an API key @@ -145,7 +148,10 @@ ptctl metafile store import --store "$PTCTL_STORE" release.torrent **Torrent detail.** `site detail` and live-site reconciliation seal a route identity into their records. M-Team detail will be added together with the -download contract so both get one reviewed, versioned identity. +download contract so both get one reviewed, versioned identity. The website's +detail page reads `/api/torrent/detail`, whose answer includes the info hash, +and also calls `/api/torrent/viewHits`, which by its name records a view; an +adapter should send only the first. **Everything else.** Bonus exchange, RSS, seeding lists, and messages are not implemented. diff --git a/docs/guide/downloader.md b/docs/guide/downloader.md index e48dd1e..657b69a 100644 --- a/docs/guide/downloader.md +++ b/docs/guide/downloader.md @@ -44,6 +44,12 @@ If the downloader refuses the login, the error names the usual cause: `rpc-whitelist` does not include the caller (behind Docker that is the bridge gateway, not 127.0.0.1) or while its anti-brute-force lock is active. +If nothing answers at all, for example because the downloader is stopped or +restarting or an SSH tunnel's far end refuses the connection, the error says +there was no response instead of naming a status. That is a reachability +problem: check that the downloader is running and the URL is reachable before +suspecting the password, and avoid retrying blindly toward the ban. + Adopt one exact materialized layout into qBittorrent or Transmission without starting it. The default action adds an absent stopped job: diff --git a/internal/downloader/qbittorrent/adapter.go b/internal/downloader/qbittorrent/adapter.go index 9a0b11e..4e86727 100644 --- a/internal/downloader/qbittorrent/adapter.go +++ b/internal/downloader/qbittorrent/adapter.go @@ -382,7 +382,9 @@ func (s *readSession) login(ctx context.Context, credential downloader.Credentia if contextErr := ctx.Err(); contextErr != nil { return contextErr } - return fmt.Errorf("qBittorrent login failed") + // Say that nothing answered, so an unreachable WebUI is not mistaken + // for rejected credentials and retried toward qBittorrent's ban. + return fmt.Errorf("qBittorrent login failed: no response from the WebUI; check that qBittorrent is running and reachable at the URL") } defer resp.Body.Close() body, err := io.ReadAll(io.LimitReader(resp.Body, 1025)) diff --git a/internal/downloader/qbittorrent/adapter_test.go b/internal/downloader/qbittorrent/adapter_test.go index 1110c7b..7b8af29 100644 --- a/internal/downloader/qbittorrent/adapter_test.go +++ b/internal/downloader/qbittorrent/adapter_test.go @@ -291,8 +291,11 @@ func TestOpenReadSessionErrorRequestCounts(t *testing.T) { if got, ok := downloader.RequestsMadeFromError(openErr); !ok || got != 1 { t.Fatalf("request count=(%d, %t), want (1, true)", got, ok) } - if strings.Contains(openErr.Error(), "CANARY-QBIT-PASSWORD") { - t.Fatalf("network error leaked credential: %v", openErr) + if strings.Contains(openErr.Error(), "CANARY-QBIT-PASSWORD") || strings.Contains(openErr.Error(), endpoint) { + t.Fatalf("network error leaked credential or endpoint: %v", openErr) + } + if !strings.Contains(openErr.Error(), "no response from the WebUI") { + t.Fatalf("network error does not say nothing answered: %v", openErr) } }) diff --git a/internal/downloader/transmission/adapter.go b/internal/downloader/transmission/adapter.go index 57fa1bc..d92c1ed 100644 --- a/internal/downloader/transmission/adapter.go +++ b/internal/downloader/transmission/adapter.go @@ -294,7 +294,7 @@ func (s *readSession) executeReader(ctx context.Context, body io.Reader, content if contextErr := ctx.Err(); contextErr != nil { return rawHTTPResponse{}, contextErr } - return rawHTTPResponse{}, fmt.Errorf("Transmission request failed") + return rawHTTPResponse{}, fmt.Errorf("Transmission request failed: no response from the RPC endpoint; check that Transmission is running and reachable at the URL") } defer resp.Body.Close() result := rawHTTPResponse{ diff --git a/internal/downloader/transmission/adapter_test.go b/internal/downloader/transmission/adapter_test.go index 17d924e..01a829b 100644 --- a/internal/downloader/transmission/adapter_test.go +++ b/internal/downloader/transmission/adapter_test.go @@ -170,6 +170,9 @@ func TestOpenTransportFailureIsCountedAndRedacted(t *testing.T) { t.Fatalf("open error leaked %q: %q", secret, err) } } + if !strings.Contains(err.Error(), "no response from the RPC endpoint") { + t.Fatalf("open error does not say nothing answered: %v", err) + } } func TestRejectedHandshakeNamesTheCause(t *testing.T) {