Repository navigation
Fix qBittorrent 5.x login failure - #99
Conversation
qBittorrent 5.x replies to /auth/login with HTTP 204 and an empty body,
while earlier versions replied 200 with the body `Ok.`. Both checks in
QBittorrentRPC rejected that valid response:
- query() treated any non-200 status as an error, so 204 raised with
`response.reason` ("OK") as the message, producing the confusing
"Failed to login ...: OK" output;
- login() required the body to equal `Ok.`.
Accept any 2xx status and treat an empty body as success alongside `Ok.`.
Verified against qBittorrent 5.1.4: login and `walk` now work.
|
Thank you. I'd like to ask you to add a test for this scenario. |
Coverage Report for CI Build 33210945552Coverage increased (+0.3%) to 67.972%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Coverage Report for CI Build 33127488465Coverage remained the same at 67.675%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions1 previously-covered line in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
test_login_qbittorrent_5 covers the 204 empty-body reply: it fails on the unpatched code with "Failed to login ...: No Content" and passes with the fix. test_login_failed keeps the negative path covered, so an unexpected body is still reported as an authentication failure.
|
Sure — added in d6793cc.
and passes with the fix.
Both use the existing |
|
Thank you. Merged. |
Description
configure_rpc qbittorrentand any subsequent RPC call fail against qBittorrent 5.x with a confusing message:The credentials are correct — the login actually succeeds. qBittorrent 5.x replies to
/api/v2/auth/loginwith HTTP 204 and an empty body, while earlier versions replied200with the bodyOk.:Two checks reject that valid response:
query()—if response.status_code != 200:treats 204 as a failure and raises withresponse.text.strip() or response.reason. The body is empty, so the message becomes the reason phraseOK, which is why the errors above readReason: OK.login()—if result.text != 'Ok.'requires the exactOk.body, which 5.x no longer sends.Changes
query()accepts any 2xx status instead of exactly 200.login()treats an empty body as success alongsideOk., so both qBittorrent 4.x and 5.x work.Verification
Tested against qBittorrent 5.1.4 (Web API on port 8068), torrt 1.2.0, Python 3.12.
Before the change
torrt walkfails at login. After:add_torrentalso works end to end — the torrent is fetched from the tracker and added to the client:Database Migration
NO