MemPalace/mempalace · error · IOError

Could not read {filepath}: {e}

Error message

Could not read {filepath}: {e}

What it means

Error "Could not read {filepath}: {e}" thrown in MemPalace/mempalace.

Source

Thrown at mempalace/normalize.py:151

        try:
            fd = os.open(filepath, flags)
        except OSError as exc:
            if exc.errno != errno.EAGAIN or not stat.S_ISREG(os.lstat(filepath).st_mode):
                raise
            fd = os.open(filepath, flags & ~getattr(os, "O_NONBLOCK", 0))
        file_stat = os.fstat(fd)
        if not stat.S_ISREG(file_stat.st_mode):
            # Text stays prefix-free: this raise is inside the ``try``, so the
            # ``except OSError`` below composes "Could not read <path>: ...".
            raise IOError("not a regular file")
        if file_stat.st_size > 500 * 1024 * 1024:  # 500 MB safety limit
            # Prefix-free for the same reason as the branch above.
            raise IOError(f"file too large ({file_stat.st_size // (1024 * 1024)} MB)")
        with os.fdopen(fd, "r", encoding="utf-8-sig", errors="replace") as f:
            fd = -1
            return f.read()
    except OSError as e:
        raise IOError(f"Could not read {filepath}: {e}") from e
    finally:
        if fd != -1:
            try:
                os.close(fd)
            except OSError:
                pass


def normalize(filepath: str) -> str:
    """
    Load a file and normalize to transcript format if it's a chat export.
    Plain text files pass through unchanged.
    """
    content = _read_transcript_file(filepath)

    if not content.strip():
        return content

View on GitHub (pinned to 06cb6987f0)

Solutions

  1. Check file permissions and that the path is readable

When it happens

Trigger: Thrown at mempalace/normalize.py:151 when the library encounters an invalid state.

Common situations: OS-level read failure (permissions, I/O error) on the transcript file.


AI-assisted analysis of MemPalace/mempalace@06cb6987f0 (2026-08-15). Data as JSON: /api/errors/f1c0ea0efc991859. Report an issue: GitHub.