{"record":{"id":"5b47372ae75b91df","repo":"gastownhall/beads","slug":"cannot-spawn-from-proxy-discovery-status-s","errorCode":null,"errorMessage":"cannot spawn from proxy discovery status %s","messagePattern":"cannot spawn from proxy discovery status (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dbproxy/proxy/endpoint.go","lineNumber":685,"sourceCode":"\tcase adoptionIdentityMismatch:\n\t\tlog.Printf(\n\t\t\t\"dbproxy: refusing proxy identity at %s (%v); quarantining only its record and starting a fresh proxy\",\n\t\t\tpidfile.Path(rootDir, PIDFileName), discovery.err,\n\t\t)\n\tcase adoptionUnverifiable:\n\t\tlog.Printf(\n\t\t\t\"dbproxy: proxy identity at %s could not be verified (%v); quarantining only its record under proxy.lock and starting a fresh proxy\",\n\t\t\tpidfile.Path(rootDir, PIDFileName), discovery.err,\n\t\t)\n\tcase adoptionLegacy:\n\t\tlog.Printf(\n\t\t\t\"dbproxy: quarantining legacy proxy record %s; a pre-upgrade proxy may still be running and must be stopped with the old bd binary if it does not idle-exit\",\n\t\t\tpidfile.Path(rootDir, PIDFileName),\n\t\t)\n\tcase adoptionMalformed:\n\t\tlog.Printf(\"dbproxy: quarantining malformed proxy record %s (%v) before restart\", pidfile.Path(rootDir, PIDFileName), discovery.err)\n\tdefault:\n\t\treturn fmt.Errorf(\"cannot spawn from proxy discovery status %s\", discovery.status)\n\t}\n\ttarget, err := quarantineRecord(rootDir, PIDFileName, time.Now())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"quarantine proxy record: %w\", err)\n\t}\n\tlog.Printf(\"dbproxy: preserved proxy record as %s\", target)\n\treturn nil\n}\n\nfunc quarantineRecord(rootDir, name string, now time.Time) (string, error) {\n\tsource := pidfile.Path(rootDir, name)\n\tfor stamp := now.Unix(); ; stamp++ {\n\t\ttarget := filepath.Join(rootDir, name+\".stale-\"+strconv.FormatInt(stamp, 10))\n\t\tif _, err := os.Lstat(target); err == nil {\n\t\t\tcontinue\n\t\t} else if !errors.Is(err, fs.ErrNotExist) {\n\t\t\treturn \"\", fmt.Errorf(\"inspect quarantine target %s: %w\", target, err)\n\t\t}","sourceCodeStart":667,"sourceCodeEnd":703,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dbproxy/proxy/endpoint.go#L667-L703","documentation":"quarantineForSpawn only knows how to quarantine records in a fixed set of discovery statuses (no record, stale-dead, identity mismatch, unverifiable, legacy, malformed). Any other status — notably adoptionIOErr, which means the pidfile could not be read for an I/O reason — reaches the default case and aborts the spawn.","triggerScenarios":"spawnAndHandoff runs quarantineForSpawn(discovery) and discovery.status is adoptionIOErr (or any new status not in the switch) because pidfile.Read failed with a non-malformed I/O error on the proxy pidfile.","commonSituations":"Filesystem permission errors on the workspace directory; the pidfile path is a directory or is locked by another tool; NFS/Windows share I/O errors; a future bd version introduces a new adoption status while an older binary path runs.","solutions":["Inspect the wrapped discovery.err (logged by earlier readAndDial path) to find the pidfile I/O error and fix permissions/disk state","Check that the workspace root is writable by the current user and the pidfile is a regular file (ls -l)","Free the file if held by another process (close editors/AV scanners) or unmount/remount a wedged network share","If a version mismatch introduced the unknown status, upgrade or match bd binaries between parent/child"],"exampleFix":"// before\ndefault:\n    return fmt.Errorf(\"cannot spawn from proxy discovery status %s\", discovery.status)\n// after\ncase adoptionIOErr:\n    return fmt.Errorf(\"cannot spawn from proxy discovery status %s: %w\", discovery.status, discovery.err)\ndefault:\n    return fmt.Errorf(\"cannot spawn from proxy discovery status %s\", discovery.status)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isSpawnableStatus(s adoptionStatus) bool {\n    switch s {\n    case adoptionNoRecord, adoptionStaleDead, adoptionIdentityMismatch,\n        adoptionUnverifiable, adoptionLegacy, adoptionMalformed:\n        return true\n    }\n    return false\n}","tryCatchPattern":"if err := quarantineForSpawn(root, discovery); err != nil {\n    var uerr *statusError\n    if errors.As(err, &uerr) {\n        log.Printf(\"pidfile I/O problem: %v\", discovery.err) // fix perms/disk, then retry\n    }\n    return err\n}","preventionTips":["Keep the workspace root writable by every user that runs bd against it","Don't make the proxy pidfile a directory, symlink chain, or read-only file","Keep all bd binaries in a workspace on the same version to avoid unknown adoption statuses","Check disk/mount health if pidfile reads start failing with I/O errors"],"tags":["pidfile","state-machine","io"],"backgroundTag":"unexpected-discovery-state","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}