{"record":{"id":"f8d3897556377875","repo":"HKUDS/Vibe-Trading","slug":"unix-socket-path-must-be-an-absolute-path","errorCode":null,"errorMessage":"unix_socket_path must be an absolute path","messagePattern":"unix_socket_path must be an absolute path","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/channels/websocket.py","lineNumber":105,"sourceCode":"    # (base64 overhead) + envelope framing stays under 36 MB; the 40 MB ceiling\n    # leaves a small margin for sender slop without opening a DoS avenue.\n    max_message_bytes: int = Field(default=37_748_736, ge=1024, le=41_943_040)\n    ping_interval_s: float = Field(default=20.0, ge=5.0, le=300.0)\n    ping_timeout_s: float = Field(default=20.0, ge=5.0, le=300.0)\n    ssl_certfile: str = \"\"\n    ssl_keyfile: str = \"\"\n\n    @field_validator(\"unix_socket_path\")\n    @classmethod\n    def unix_socket_path_format(cls, value: str) -> str:\n        value = value.strip()\n        if not value:\n            return \"\"\n        if \"\\x00\" in value:\n            raise ValueError(\"unix_socket_path must not contain NUL bytes\")\n        path = Path(value).expanduser()\n        if not path.is_absolute():\n            raise ValueError(\"unix_socket_path must be an absolute path\")\n        return str(path)\n\n    @field_validator(\"path\")\n    @classmethod\n    def path_must_start_with_slash(cls, value: str) -> str:\n        if not value.startswith(\"/\"):\n            raise ValueError('path must start with \"/\"')\n        return _normalize_config_path(value)\n\n    @field_validator(\"token_issue_path\")\n    @classmethod\n    def token_issue_path_format(cls, value: str) -> str:\n        value = value.strip()\n        if not value:\n            return \"\"\n        if not value.startswith(\"/\"):\n            raise ValueError('token_issue_path must start with \"/\"')\n        return _normalize_config_path(value)","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/channels/websocket.py#L87-L123","documentation":"Raised when unix_socket_path (after ~ expansion via Path.expanduser) is not absolute, e.g. \"run/app.sock\" or \"./app.sock\". Binding a relative unix socket path depends on the process's current working directory, which makes the socket location unpredictable, so an absolute path is required.","triggerScenarios":"Setting unix_socket_path=\"app.sock\", \"./tmp/ws.sock\", or \"~/sockets/ws.sock\" where ~ fails to expand (HOME unset). Path(value).expanduser().is_absolute() is False, so the validator raises.","commonSituations":"Using a relative path that worked in one working directory but breaks under systemd/containers where cwd differs; templating config with a missing leading slash; HOME not set in a hardened service environment so expanduser() is a no-op on a ~/... path.","solutions":["Use a fully qualified absolute path like \"/var/run/app/ws.sock\"","If using ~, ensure HOME is set in the service environment (systemd: Environment= or WorkingDirectory plus absolute path preferred)","Create the parent directory and confirm permissions before starting the channel"],"exampleFix":"# before\nunix_socket_path = \"./ws.sock\"\n# after\nunix_socket_path = \"/var/run/myapp/ws.sock\"","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef ok_socket_path(p: str) -> bool:\n    v = p.strip()\n    return v == \"\" or (\"\\x00\" not in v and Path(v).expanduser().is_absolute())","typeGuard":"def is_absolute_socket_path(p: str) -> bool:\n    return Path(p.strip()).expanduser().is_absolute()","tryCatchPattern":null,"preventionTips":["Standardize on absolute paths like /run/<app>/ws.sock in config templates","Ensure HOME is set if you rely on ~ expansion","Add a config lint that asserts all path fields are absolute"],"tags":["websocket","unix-socket","absolute-path","config-validation"],"backgroundTag":"config-validation-failed","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}