{"record":{"id":"ae92d3dc31564b3e","repo":"binary-husky/gpt_academic","slug":"path-ae92d3","errorCode":null,"errorMessage":"没有读取权限: {path}","messagePattern":"没有读取权限: (.+?)","errorType":"exception","errorClass":"PermissionError","httpStatus":null,"severity":"error","filePath":"crazy_functions/doc_fns/read_fns/markitdown/markdown_reader.py","lineNumber":127,"sourceCode":"            max_size_mb: 允许的最大文件大小(MB)\n\n        Returns:\n            Path: 验证后的Path对象\n\n        Raises:\n            ValueError: 文件不存在、格式不支持或大小超限\n            PermissionError: 没有读取权限\n        \"\"\"\n        path = Path(file_path).resolve()\n\n        if not path.exists():\n            raise ValueError(f\"文件不存在: {path}\")\n\n        if not path.is_file():\n            raise ValueError(f\"不是一个文件: {path}\")\n\n        if not os.access(path, os.R_OK):\n            raise PermissionError(f\"没有读取权限: {path}\")\n\n        file_size_mb = path.stat().st_size / (1024 * 1024)\n        if file_size_mb > max_size_mb:\n            raise ValueError(\n                f\"文件大小 ({file_size_mb:.1f}MB) 超过限制 {max_size_mb}MB\"\n            )\n\n        if path.suffix.lower() not in self.SUPPORTED_EXTENSIONS:\n            raise ValueError(\n                f\"不支持的格式: {path.suffix}. \"\n                f\"支持的格式: {', '.join(sorted(self.SUPPORTED_EXTENSIONS))}\"\n            )\n\n        return path\n\n    def _cleanup_text(self, text: str) -> str:\n        \"\"\"清理文本\n","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/binary-husky/gpt_academic/blob/d6bde0fa54373309bd05823a49bda8da019d2c77/crazy_functions/doc_fns/read_fns/markitdown/markdown_reader.py#L109-L145","documentation":"Third precondition of MarkdownConverter._validate_file: os.access(path, os.R_OK) is false — the file exists and is a file but the current process cannot read it — raising PermissionError('没有读取权限: <path>').","triggerScenarios":"File owned by another user/mode 600; containerized process with mismatched UID on a bind mount; Windows ACL denial.","commonSituations":"Docker deployments mounting host directories; files created by root then read by an app user; SELinux denying container access.","solutions":["ls -l the path and compare with the process user (id)","chmod +r / chown appropriately, or run the process as a user with read access","In Docker, ensure the mount is readable by the container user and SELinux labels permit it (:z on the mount)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import os\n\nif not os.access(pdf_path, os.R_OK):\n    raise PermissionError(f'no read access to {pdf_path}; fix ownership/mode')","typeGuard":null,"tryCatchPattern":"try:\n    md = converter.convert(pdf)\nexcept PermissionError as e:\n    alert_ops(str(e))  # path included; fix ACLs/UID\n    raise","preventionTips":["Match container UID with mounted file ownership or chmod +r the inputs","Pre-check os.access(p, os.R_OK) at request intake","Watch SELinux/AppArmor denials in containerized setups"],"tags":["permissions","file-validation","docker","pdf","python"],"backgroundTag":null,"analyzedSha":"d6bde0fa54373309bd05823a49bda8da019d2c77","analyzedAt":"2026-08-14T22:48:35.038Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}