Skip to content

fix: report actionable diagnostic for overlong unix socket paths - #13

Open
Vrindakr3300 wants to merge 1 commit into
Cod-Hash-Studios:mainfrom
Vrindakr3300:fix/overlong-unix-socket-path-diagnostic
Open

fix: report actionable diagnostic for overlong unix socket paths#13
Vrindakr3300 wants to merge 1 commit into
Cod-Hash-Studios:mainfrom
Vrindakr3300:fix/overlong-unix-socket-path-diagnostic

Conversation

@Vrindakr3300

Copy link
Copy Markdown

Summary

Detects overlong Unix socket paths before bind, connect, or daemon spawn operations on Unix platforms, failing fast with an actionable diagnostic message instead of encountering a low-level bind failure or generic 15-second server readiness timeout.

Closes #3

Key Changes

  • Path Validation & Diagnostic Error (src/ipc.rs):
    • Added max_unix_socket_path_len() inspecting libc::sockaddr_un's sun_path length minus null byte (103 bytes on macOS/BSDs, 107 bytes on Linux).
    • Added validate_socket_path() returning an InvalidInput error with the configured path, byte length vs. platform limit, and remediation suggestion (set a shorter NAGI_CONFIG_PATH or XDG_CONFIG_HOME).
    • Integrated path validation into bind_local_listener, connect_local_stream, and prepare_socket_path.
  • Pre-spawn & Readiness Validation (src/server/autodetect.rs):
    • Validates both API (socket_path()) and client (client_socket_path()) paths at entry of auto_detect_launch() and wait_for_server_socket().
  • Unit Coverage:
    • Added unit tests in src/ipc.rs, src/server/autodetect.rs, and src/server/socket_paths.rs verifying path limit enforcement and error diagnostics.

Example Output

socket path exceeds Unix domain socket limit (120 bytes > 103 bytes): /path/to/deeply/nested/nagi.sock; set a shorter NAGI_CONFIG_PATH or XDG_CONFIG_HOME

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle overlong Unix socket paths with an actionable diagnostic

1 participant