# Buggy code
def render_GET(self, request):
    """
    .. http:get:: /libtorrent/settings

    A GET request to this endpoint will return information about libtorrent.

        **Example request**:

            .. sourcecode:: none

                curl -X GET http://localhost:8085/libtorrent/settings?hop=0

        **Example response**:

            .. sourcecode:: javascript

                {
                    "hop": 0,
                    "settings": {
                        "urlseed_wait_retry": 30,
                        "enable_upnp": true,
                        ...
                        "send_socket_buffer_size": 0,
                        "lock_disk_cache": false,
                        "i2p_port": 0
                    }
                }
    """
    args = recursive_unicode(request.args)
    hop = 0
    if "hop" in args and args["hop"]:
        hop = int(args["hop"][0])

    if hop not in self.session.lm.ltmgr.ltsessions:
        return json.twisted_dumps({"hop": hop, "settings": {}})

    lt_session = self.session.lm.ltmgr.ltsessions[hop]
    if hop == 0:
        lt_settings = self.session.lm.ltmgr.ltsettings[lt_session]
        lt_settings["peer_fingerprint"] = hexlify(lt_settings["peer_fingerprint"])
    else:
        lt_settings = lt_session.get_settings()

    return json.twisted_dumps({"hop": hop, "settings": lt_settings})


# Traceback (AttributeError)
INFO    1575206079.86             LibtorrentMgr:671  (LibtorrentMgr)  start_download: Starting in VOD mode
ERROR   1575206081.50    LibtorrentDownloadImpl:805  (LibtorrentDownloadImpl)  Resume data failed to save: <class 'Tribler.Core.exceptions.SaveResumeDataError'>: torrent has no metadata
INFO    1575206091.40                    tunnel:469  (Swarm)  Skipping lookup for swarm b'...'
INFO    1575206101.40                    tunnel:462  (Swarm)  Performing DHT lookup for swarm b'...'
INFO    1575206109.52    LibtorrentDownloadImpl:452  (LibtorrentDownloadImpl)  LibtorrentDownloadImpl: skipping set_piece_priority
Traceback (most recent call last):
File "Tribler\Core\Video\VideoServer.py", line 102, in process_request_thread
File "lib\socketserver.py", line 360, in finish_request
File "Tribler\Core\Video\VideoServer.py", line 124, in __init__
File "lib\socketserver.py", line 720, in __init__
File "lib\http\server.py", line 426, in handle
File "lib\http\server.py", line 414, in handle_one_request
File "Tribler\Core\Video\VideoServer.py", line 197, in do_GET
File "Tribler\Core\Video\VideoServer.py", line 76, in get_vod_stream
File "Tribler\Core\Video\VideoServer.py", line 91, in get_vod_destination
AttributeError: 'LibtorrentDownloadImpl' object has no attribute 'get_selected_files'
ERROR   1575206111.41                      util:68   (ipv8.util)  Deferred errback fired: [Failure instance: Traceback (failure with no frames): <class 'RuntimeError'>: Peers request timeout

# Fixed code
def render_GET(self, request):
    """
    .. http:get:: /libtorrent/settings

    A GET request to this endpoint will return information about libtorrent.

        **Example request**:

            .. sourcecode:: none

                curl -X GET http://localhost:8085/libtorrent/settings?hop=0

        **Example response**:

            .. sourcecode:: javascript

                {
                    "hop": 0,
                    "settings": {
                        "urlseed_wait_retry": 30,
                        "enable_upnp": true,
                        ...
                        "send_socket_buffer_size": 0,
                        "lock_disk_cache": false,
                        "i2p_port": 0
                    }
                }
    """
    args = recursive_unicode(request.args)
    hop = 0
    if "hop" in args and args["hop"]:
        hop = int(args["hop"][0])

    if hop not in self.session.lm.ltmgr.ltsessions:
        return json.twisted_dumps({"hop": hop, "settings": {}})

    lt_session = self.session.lm.ltmgr.ltsessions[hop]
    if hop == 0:
        lt_settings = self.session.lm.ltmgr.get_session_settings(lt_session)
        lt_settings["peer_fingerprint"] = hexlify(lt_settings["peer_fingerprint"])
    else:
        lt_settings = lt_session.get_settings()

    return json.twisted_dumps({"hop": hop, "settings": lt_settings})