{"record":{"id":"2be48edf85d12028","repo":"Fosowl/agenticSeek","slug":"permission-denied-to-read-prompt-file-at-path-fi","errorCode":null,"errorMessage":"Permission denied to read prompt file at path: {file_path}","messagePattern":"Permission denied to read prompt file at path: (.+?)","errorType":"exception","errorClass":"PermissionError","httpStatus":null,"severity":"error","filePath":"sources/agents/agent.py","lineNumber":119,"sourceCode":"        return list(self.tools.keys())\n    \n    def get_tools_description(self) -> str:\n        \"\"\"\n        Get the list of tools names and their description.\n        \"\"\"\n        description = \"\"\n        for name in self.get_tools_name():\n            description += f\"{name}: {self.tools[name].description}\\n\"\n        return description\n    \n    def load_prompt(self, file_path: str) -> str:\n        try:\n            with open(file_path, 'r', encoding=\"utf-8\") as f:\n                return f.read()\n        except FileNotFoundError:\n            raise FileNotFoundError(f\"Prompt file not found at path: {file_path}\")\n        except PermissionError:\n            raise PermissionError(f\"Permission denied to read prompt file at path: {file_path}\")\n        except Exception as e:\n            raise e\n    \n    def request_stop(self) -> None:\n        \"\"\"\n        Request the agent to stop.\n        \"\"\"\n        self.stop = True\n        self.status_message = \"Stopped\"\n    \n    @abstractmethod\n    def process(self, prompt, speech_module) -> str:\n        \"\"\"\n        abstract method, implementation in child class.\n        Process the prompt and return the answer of the agent.\n        \"\"\"\n        pass\n","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/Fosowl/agenticSeek/blob/ae57a2357745a9706cb12d0fd76d954c84d166fa/sources/agents/agent.py#L101-L137","documentation":"load_prompt() converts PermissionError into a clear message when the prompt file exists but the current process lacks read permission. Like the FileNotFoundError branch, it is raised during load_prompt, typically from Agent.__init__. The chained cause is preserved as a new PermissionError with the path in the message.","triggerScenarios":"Calling load_prompt(file_path) (directly or via __init__) where open(file_path, 'r') raises PermissionError — e.g. file owned by another user, mode 000/0600, or a protected directory in the path.","commonSituations":"Prompt file created by root with restrictive permissions while the app runs as a service user; secrets-like permissions (chmod 600) applied to prompt files; running in a container as non-root against a host-mounted file; SELinux/AppArmor denials.","solutions":["Fix permissions: chmod o+r (or appropriate group perms) on the prompt file and ensure the containing directories are traversable.","Run the process as a user with read access, or chown the file to the service user.","If in a container, confirm the mounted file is readable by the container's UID.","Verify with `sudo -u <appuser> cat <file>` that the runtime user can read it."],"exampleFix":"// before\n-rw------- root root prompts/system.txt  # app user cannot read\n// after\nchmod 644 prompts/system.txt   # or chown appuser prompts/system.txt","handlingStrategy":"validation","validationCode":"import os\ndef assert_readable(path: str) -> None:\n    if not os.access(path, os.R_OK):\n        raise PermissionError(\n            f\"Process user ({os.getuid()}) cannot read {path}; \"\n            \"fix with chmod/chown before starting\"\n        )\nassert_readable(prompt_path)\nagent = Agent(prompt_path=prompt_path)","typeGuard":null,"tryCatchPattern":"try:\n    agent = Agent(prompt_path=path)\nexcept PermissionError as e:\n    logger.error(\"Cannot read prompt %s: run `chmod o+r %s` or chown to the service user\", path, path)\n    raise SystemExit(1) from e","preventionTips":["Ensure prompt files are world-readable or owned by the service user (chmod 644, correct chown).","Avoid creating prompt files as root with umask 077 during setup scripts.","In containers, match the mounted file's ownership to the container's runtime UID.","Smoke-test with `sudo -u <appuser> cat <file>` before deploying."],"tags":["python","permissions","filesystem","configuration"],"backgroundTag":"permission-denied","analyzedSha":"ae57a2357745a9706cb12d0fd76d954c84d166fa","analyzedAt":"2026-08-30T02:49:05.834Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}