HelloZeroNet/ZeroNet · error · RequestError

File not readable at position: %s

Error message

File not readable at position: %s

What it means

RequestError raised in handleGetFile when isReadable() fails for a large file: the requested position (params['location']) falls in a range the server refuses to read (e.g. beyond the allowed streaming window or invalid seek offset for the served file). It is a per-request guard protecting big-file reads.

Source

Thrown at src/File/FileRequest.py:230

        if not site or not site.isServing():  # Site unknown or not serving
            self.response({"error": "Unknown site"})
            self.connection.badAction(5)
            return False
        try:
            file_path = site.storage.getPath(params["inner_path"])
            if streaming:
                file_obj = site.storage.open(params["inner_path"])
            else:
                file_obj = Msgpack.FilePart(file_path, "rb")

            with file_obj as file:
                file.seek(params["location"])
                read_bytes = params.get("read_bytes", FILE_BUFF)
                file_size = os.fstat(file.fileno()).st_size

                if file_size > read_bytes:  # Check if file is readable at current position (for big files)
                    if not self.isReadable(site, params["inner_path"], file, params["location"]):
                        raise RequestError("File not readable at position: %s" % params["location"])
                else:
                    if params.get("file_size") and params["file_size"] != file_size:
                        self.connection.badAction(2)
                        raise RequestError("File size does not match: %sB != %sB" % (params["file_size"], file_size))

                if not streaming:
                    file.read_bytes = read_bytes

                if params["location"] > file_size:
                    self.connection.badAction(5)
                    raise RequestError("Bad file location")

                if streaming:
                    back = {
                        "size": file_size,
                        "location": min(file.tell() + read_bytes, file_size),
                        "stream_bytes": min(read_bytes, file_size - params["location"])
                    }

View on GitHub (pinned to 454c0b2e7e)

Solutions

  1. Client should reset its download location to a valid, previously verified offset and retry
  2. Ensure params['location'] is within the file's actual size before requesting
  3. Catch RequestError in the request handler and return an error response to the peer instead of crashing
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/File/FileRequest.py:230 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HelloZeroNet/ZeroNet@454c0b2e7e (2026-09-02). Data as JSON: /api/errors/c3eb39bf6a048723. Report an issue: GitHub.