{"record":{"id":"8928b12d8d70e088","repo":"MemPalace/mempalace","slug":"could-not-read-filepath-not-a-regular-file","errorCode":null,"errorMessage":"Could not read {filepath}: not a regular file","messagePattern":"Could not read (.+?): not a regular file","errorType":"exception","errorClass":"IOError","httpStatus":null,"severity":"error","filePath":"mempalace/normalize.py","lineNumber":143,"sourceCode":"    # blocking open of a FIFO waits in the kernel for a writer, so the\n    # S_ISREG test never runs. See ``miner._read_text_no_follow``, including\n    # why the EAGAIN branch re-checks the type and retries without the flag.\n    flags = os.O_RDONLY | getattr(os, \"O_NOFOLLOW\", 0) | getattr(os, \"O_NONBLOCK\", 0)\n    if os.path.islink(filepath):\n        raise IOError(f\"Could not read {filepath}: symlinked files are skipped\")\n    fd = -1\n    try:\n        try:\n            fd = os.open(filepath, flags)\n        except OSError as exc:\n            if exc.errno != errno.EAGAIN or not stat.S_ISREG(os.lstat(filepath).st_mode):\n                raise\n            fd = os.open(filepath, flags & ~getattr(os, \"O_NONBLOCK\", 0))\n        file_stat = os.fstat(fd)\n        if not stat.S_ISREG(file_stat.st_mode):\n            # Text stays prefix-free: this raise is inside the ``try``, so the\n            # ``except OSError`` below composes \"Could not read <path>: ...\".\n            raise IOError(\"not a regular file\")\n        if file_stat.st_size > 500 * 1024 * 1024:  # 500 MB safety limit\n            # Prefix-free for the same reason as the branch above.\n            raise IOError(f\"file too large ({file_stat.st_size // (1024 * 1024)} MB)\")\n        with os.fdopen(fd, \"r\", encoding=\"utf-8-sig\", errors=\"replace\") as f:\n            fd = -1\n            return f.read()\n    except OSError as e:\n        raise IOError(f\"Could not read {filepath}: {e}\") from e\n    finally:\n        if fd != -1:\n            try:\n                os.close(fd)\n            except OSError:\n                pass\n\n\ndef normalize(filepath: str) -> str:\n    \"\"\"","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/normalize.py#L125-L161","documentation":"Error \"Could not read {filepath}: not a regular file\" thrown in MemPalace/mempalace.","triggerScenarios":"Thrown at mempalace/normalize.py:143 when the library encounters an invalid state.","commonSituations":"The transcript path was not a regular file.","solutions":["Pass a path to a regular file (not a directory, socket, or device)"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}