{"record":{"id":"1d89c4d2a2bf3f25","repo":"MemPalace/mempalace","slug":"refusing-symlinked-file-path","errorCode":null,"errorMessage":"Refusing symlinked file: {path}","messagePattern":"Refusing symlinked file: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"mempalace/repair.py","lineNumber":78,"sourceCode":"\n\ndef _no_follow_flag() -> int:\n    return getattr(os, \"O_NOFOLLOW\", 0)\n\n\ndef _non_blocking_flag() -> int:\n    \"\"\"Return O_NONBLOCK, or 0 where the platform has no such flag (Windows).\n\n    Without it the ``S_ISREG`` refusal in ``_open_regular_file_no_follow``\n    is unreachable for a FIFO: opening one for reading blocks in the kernel\n    until a writer appears, so ``repair`` would wedge instead of refusing.\n    \"\"\"\n    return getattr(os, \"O_NONBLOCK\", 0)\n\n\ndef _open_regular_file_no_follow(path: str) -> int:\n    if os.path.islink(path):\n        raise RuntimeError(f\"Refusing symlinked file: {path}\")\n    flags = os.O_RDONLY | _no_follow_flag() | _non_blocking_flag()\n    try:\n        fd = os.open(path, flags)\n    except OSError as exc:\n        # EAGAIN here is a write-lease break, which the kernel grants on\n        # regular files only, so re-check the type and open the way this\n        # helper did before the flag existed. Anything else propagates.\n        if exc.errno != errno.EAGAIN or not stat.S_ISREG(os.lstat(path).st_mode):\n            raise\n        fd = os.open(path, flags & ~_non_blocking_flag())\n    try:\n        st = os.fstat(fd)\n        if not stat.S_ISREG(st.st_mode):\n            raise RuntimeError(f\"Refusing non-regular file: {path}\")\n        return fd\n    except Exception:\n        os.close(fd)\n        raise","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/repair.py#L60-L96","documentation":"Error \"Refusing symlinked file: {path}\" thrown in MemPalace/mempalace.","triggerScenarios":"Thrown at mempalace/repair.py:78 when the library encounters an invalid state.","commonSituations":"Repair refuses to operate on symlinked files.","solutions":["Replace the symlink with the real file"],"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"}