{"record":{"id":"b9dfd946b52b6738","repo":"gastownhall/beads","slug":"failed-to-get-hostname-w","errorCode":null,"errorMessage":"failed to get hostname: %w","messagePattern":"failed to get hostname: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/beads/fingerprint.go","lineNumber":155,"sourceCode":"\t}\n\n\treturn filepath.ToSlash(evalPath), nil\n}\n\n// GetCloneID generates a unique ID for this specific clone (not shared with other clones)\nfunc GetCloneID() (string, error) {\n\treturn GetCloneIDForPath(\"\")\n}\n\n// GetCloneIDForPath generates a unique ID for the specific clone rooted at or\n// containing repoPath. An empty repoPath uses the current cwd.\n//\n// GH#2867: Uses the main repo root (not worktree root) so that all worktrees\n// sharing a database produce the same clone ID.\nfunc GetCloneIDForPath(repoPath string) (string, error) {\n\thostname, err := os.Hostname()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get hostname: %w\", err)\n\t}\n\n\trepoRoot, err := mainRepoRootForPath(repoPath)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"not a git repository: %w\", err)\n\t}\n\n\tnormalizedPath := normalizedRepoPath(repoRoot)\n\thash := sha256.Sum256([]byte(hostname + \":\" + normalizedPath))\n\treturn hex.EncodeToString(hash[:8]), nil\n}\n\nfunc runGitInRepo(repoPath string, args ...string) ([]byte, error) {\n\tcmd := exec.Command(\"git\", args...)\n\tif repoPath != \"\" {\n\t\tcmd.Dir = repoPath\n\t}\n\treturn cmd.Output()","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/beads/fingerprint.go#L137-L173","documentation":"GetCloneIDForPath builds a clone identifier from hostname + normalized main repo path. Its first step is os.Hostname(); if the OS cannot report a hostname, the failure is wrapped as \"failed to get hostname\". Without a hostname the clone ID would not be unique per machine, so bd refuses to guess.","triggerScenarios":"Calling GetCloneID/GetCloneIDForPath on a system where os.Hostname() returns an error — severely restricted environments, containers with no set hostname, or exotic sandboxes where the utsname is unavailable.","commonSituations":"Minimal containers/chroots without a configured hostname; hardened sandboxes blocking uname; embedded systems with unset machine names; test environments faking syscalls.","solutions":["Set a hostname for the environment (e.g. `hostnamectl set-hostname myhost` or Docker `--hostname myhost`)","Fix /etc/hostname (or the platform equivalent) and restart the process","Check sandbox/seccomp policies that block uname/gethostname syscalls","If it is transient, retry — os.Hostname failures are rarely retriable but a container restart usually resolves it"],"exampleFix":"// docker run before\n$ docker run acme/bd\n// after\n$ docker run --hostname devbox acme/bd\n","handlingStrategy":"retry","validationCode":"if _, err := os.Hostname(); err != nil {\n    // fix environment hostname before using clone-ID APIs\n}","typeGuard":null,"tryCatchPattern":"cloneID, err := beads.GetCloneIDForPath(path)\nif err != nil && strings.Contains(err.Error(), \"failed to get hostname\") {\n    return fmt.Errorf(\"set a hostname for this environment: %w\", err)\n}","preventionTips":["Always configure a hostname in containers (--hostname) and chroots","Keep /etc/hostname valid on minimal systems","Check sandbox policies don't block gethostname/uname","Retry after container restart if the failure was transient"],"tags":["hostname","os","clone-id"],"backgroundTag":"hostname-unavailable","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}