Opened 5 months ago

#3366 new bug

WebApi.add_torrents(): deferred RPC failure results are not propagated

Reported by: lalbornoz Owned by:
Priority: minor Milestone: needs verified
Component: Web UI Version: 2.0.3
Keywords: add_torrents duplicate Cc:

Description

Failure results in response to deferred RPC requests issued by WebApi.add_torrents() are not propagated, culminating in an exception leak:

Mar 20 18:22:52 [REDACTED] deluge-web[24012]: 18:22:52 [ERROR   ][deluge.ui.client           :169 ] RPCError Message Received!
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: --------------------------------------------------------------------------------
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: RPCRequest: core.add_torrent_file_async(tmplxdf2alp.torrent, b'[ ... ]
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: --------------------------------------------------------------------------------
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: Traceback (most recent call last):
Mar 20 18:22:52 [REDACTED] deluge-web[24012]:   File "/usr/lib/python3/dist-packages/deluge/core/rpcserver.py", line 326, in dispatch
Mar 20 18:22:52 [REDACTED] deluge-web[24012]:     ret = self.factory.methods[method](*args, **kwargs)
Mar 20 18:22:52 [REDACTED] deluge-web[24012]:   File "/usr/lib/python3/dist-packages/deluge/core/core.py", line 430, in add_torrent_file_async
Mar 20 18:22:52 [REDACTED] deluge-web[24012]:     save_state=save_state,
Mar 20 18:22:52 [REDACTED] deluge-web[24012]:   File "/usr/lib/python3/dist-packages/deluge/core/torrentmanager.py", line 602, in add_async
Mar 20 18:22:52 [REDACTED] deluge-web[24012]:     torrent_info, magnet, options, resume_data
Mar 20 18:22:52 [REDACTED] deluge-web[24012]:   File "/usr/lib/python3/dist-packages/deluge/core/torrentmanager.py", line 446, in _build_torrent_params
Mar 20 18:22:52 [REDACTED] deluge-web[24012]:     raise AddTorrentError('Torrent already in session (%s).' % torrent_id)
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: deluge.error.AddTorrentError: Torrent already in session ([REDACTED]).
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: AddTorrentError: Torrent already in session ([REDACTED]).
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: --------------------------------------------------------------------------------
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: 18:22:52 [ERROR   ][deluge.ui.web.json_api     :185 ] [Failure instance: Traceback: <class 'TypeError'>: Object of type 'Failure' is not JSON serializable
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3/dist-packages/twisted/internet/defer.py:653:_runCallbacks
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3/dist-packages/twisted/internet/defer.py:1117:_cbDeferred
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3/dist-packages/twisted/internet/defer.py:459:callback
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3/dist-packages/twisted/internet/defer.py:567:_startRunCallbacks
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: --- <exception caught here> ---
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3/dist-packages/twisted/internet/defer.py:653:_runCallbacks
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3/dist-packages/deluge/ui/web/json_api.py:179:_on_rpc_request_finished
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3/dist-packages/deluge/ui/web/json_api.py:232:_send_response
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3.6/json/__init__.py:231:dumps
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3.6/json/encoder.py:199:encode
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3.6/json/encoder.py:257:iterencode
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3.6/json/encoder.py:180:default
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: ]
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: Unhandled error in Deferred:
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: 18:22:52 [CRITICAL][twisted                    :154 ] Unhandled error in Deferred:
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: 18:22:52 [CRITICAL][deluge.log                 :93  ] twisted.internet.defer
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: [Failure instance: Traceback: <class 'TypeError'>: Object of type 'Failure' is not JSON serializable
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3/dist-packages/twisted/internet/defer.py:653:_runCallbacks
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3/dist-packages/twisted/internet/defer.py:1117:_cbDeferred
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3/dist-packages/twisted/internet/defer.py:459:callback
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3/dist-packages/twisted/internet/defer.py:567:_startRunCallbacks
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: --- <exception caught here> ---
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3/dist-packages/twisted/internet/defer.py:653:_runCallbacks
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3/dist-packages/deluge/ui/web/json_api.py:190:_on_rpc_request_failed
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3/dist-packages/deluge/ui/web/json_api.py:232:_send_response
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3.6/json/__init__.py:231:dumps
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3.6/json/encoder.py:199:encode
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3.6/json/encoder.py:257:iterencode
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: /usr/lib/python3.6/json/encoder.py:180:default
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: ]
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: Unhandled error in Deferred:
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: 18:22:52 [CRITICAL][twisted                    :154 ] Unhandled error in Deferred:
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: 18:22:52 [CRITICAL][deluge.log                 :93  ] twisted.internet.defer
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: [Failure instance: Traceback (failure with no frames): <class 'deluge.error.AddTorrentError'>: Torrent already in session ([REDACTED]).
Mar 20 18:22:52 [REDACTED] deluge-web[24012]: ]

The patch enclosed passes consumeErrors=True and fireOnOneErrback=True to the DeferredList() constructor in WebApi.add_torrents() in order to ensure that the DeferredList() will both fire on failure and halt further propagation past JSON._on_rpc_request_failed().

Attachments (1)

deluge-2.0.3+add_torrents_fix.patch (497 bytes) - added by lalbornoz 5 months ago.

Download all attachments as: .zip

Change History (1)

Changed 5 months ago by lalbornoz

Note: See TracTickets for help on using tickets.