# Buggy code
def process_uri_request(self):
    """
    Process a URI request if we have one in the queue.
    """
    if len(self.pending_uri_requests) == 0:
        return

    uri = self.pending_uri_requests.pop()

    # TODO: create a proper confirmation dialog to show results of adding .mdblob files
    # the case for .mdblob files is handled without torrentinfo endpoint
    if uri.startswith("file") and uri.endswith(".mdblob"):
        request_mgr = TriblerRequestManager()
        request_mgr.perform_request(
            "downloads", lambda _: None, method="PUT", data={"uri": uri}
        )
        return

    if uri.startswith("file") or uri.startswith("magnet"):
        self.start_download_from_uri(uri)


# Traceback (PackError)
ERROR   1562070054.96              rest_manager:83   (RESTRequest)  [Failure instance: Traceback: <class 'ipv8.messaging.serialization.PackError'>: Could not pack item 9: varlenI
error: unpack_from requires a buffer of at least 1869967971 bytes
/home/tribler/.local/lib/python2.7/site-packages/twisted/web/http.py:2121:_finishRequestBody
/home/tribler/.local/lib/python2.7/site-packages/twisted/web/http.py:2196:allContentReceived
/home/tribler/.local/lib/python2.7/site-packages/twisted/web/http.py:920:requestReceived
/home/tribler/tudelft/tribler/Tribler/Core/Modules/restapi/rest_manager.py:118:process
--- <exception caught here> ---
/home/tribler/.local/lib/python2.7/site-packages/twisted/web/server.py:199:process
/home/tribler/.local/lib/python2.7/site-packages/twisted/web/server.py:259:render
/home/tribler/.local/lib/python2.7/site-packages/twisted/web/resource.py:250:render
/home/tribler/tudelft/tribler/Tribler/Core/Modules/restapi/downloads_endpoint.py:347:render_PUT
/home/tribler/tudelft/tribler/Tribler/Core/Modules/MetadataStore/serialization.py:166:from_file
/home/tribler/tudelft/tribler/Tribler/Core/Modules/MetadataStore/serialization.py:135:from_signed_blob
/home/tribler/tudelft/tribler/Tribler/Core/Modules/MetadataStore/serialization.py:140:from_signed_blob_with_offset
/home/tribler/tudelft/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py:328:unpack_multiple
/home/tribler/tudelft/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py:320:unpack_multiple
/home/tribler/tudelft/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py:297:unpack
/home/tribler/tudelft/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py:160:unpack_from
]
Traceback (most recent call last):
File "/home/tribler/.local/lib/python2.7/site-packages/twisted/web/server.py", line 199, in process
self.render(resrc)
File "/home/tribler/.local/lib/python2.7/site-packages/twisted/web/server.py", line 259, in render
body = resrc.render(self)
File "/home/tribler/.local/lib/python2.7/site-packages/twisted/web/resource.py", line 250, in render
return m(request)
File "/home/tribler/tudelft/tribler/Tribler/Core/Modules/restapi/downloads_endpoint.py", line 347, in render_PUT
payload = ChannelMetadataPayload.from_file(filename)
File "/home/tribler/tudelft/tribler/Tribler/Core/Modules/MetadataStore/serialization.py", line 166, in from_file
return cls.from_signed_blob(f.read())
File "/home/tribler/tudelft/tribler/Tribler/Core/Modules/MetadataStore/serialization.py", line 135, in from_signed_blob
return cls.from_signed_blob_with_offset(data, check_signature)[0]
File "/home/tribler/tudelft/tribler/Tribler/Core/Modules/MetadataStore/serialization.py", line 140, in from_signed_blob_with_offset
unpack_list, end_offset = default_serializer.unpack_multiple(cls.format_list, data, offset=offset)
File "/home/tribler/tudelft/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 328, in unpack_multiple
sys.exc_info()[2])
File "/home/tribler/tudelft/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 320, in unpack_multiple
unpacked, unpacked_size = self.unpack(format, data, current_offset)
File "/home/tribler/tudelft/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 297, in unpack
return self._packers[format].unpack_from(data, offset)
File "/home/tribler/tudelft/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 160, in unpack_from
out, = unpack_from('>%ds' % length, data, offset + self.format_size)
PackError: Could not pack item 9: varlenI
error: unpack_from requires a buffer of at least 1869967971 bytes

# Fixed code
def process_uri_request(self):
    """
    Process a URI request if we have one in the queue.
    """
    if len(self.pending_uri_requests) == 0:
        return

    uri = self.pending_uri_requests.pop()

    # TODO: create a proper confirmation dialog to show results of adding .mdblob files
    # the case for .mdblob files is handled without torrentinfo endpoint
    if uri.startswith("file") and (
        uri.endswith(".mdblob") or uri.endswith(".mdblob.lz4")
    ):
        request_mgr = TriblerRequestManager()
        request_mgr.perform_request(
            "downloads", lambda _: None, method="PUT", data={"uri": uri}
        )
        return

    if uri.startswith("file") or uri.startswith("magnet"):
        self.start_download_from_uri(uri)