{"record":{"id":"2b355ec8a26c03ce","repo":"gastownhall/beads","slug":"errkindmismatch","errorCode":"ErrKindMismatch","errorMessage":"pidfile: kind mismatch","messagePattern":"pidfile: kind mismatch","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dbproxy/pidfile/pidfile.go","lineNumber":35,"sourceCode":"\tSchema      int    `json:\"schema,omitempty\"`\n\tKind        string `json:\"kind,omitempty\"`\n\tBirth       string `json:\"birth,omitempty\"`\n\tRootID      string `json:\"root_id,omitempty\"`\n\tControlPort int    `json:\"control_port,omitempty\"`\n}\n\nconst SchemaV2 = 2\n\nconst (\n\tKindProxy       = \"db-proxy\"\n\tKindDoltBackend = \"dolt-backend\"\n)\n\nvar (\n\tErrLegacySchema = errors.New(\"pidfile: legacy schema\")\n\tErrBadPid       = errors.New(\"pidfile: invalid pid\")\n\tErrBadPort      = errors.New(\"pidfile: invalid port\")\n\tErrKindMismatch = errors.New(\"pidfile: kind mismatch\")\n\tErrMissingBirth = errors.New(\"pidfile: missing birth token\")\n)\n\n// ValidateV2 validates the fields required for a schema v2 pidfile.\nfunc (p *PidFile) ValidateV2(wantKind string) error {\n\tif p.Schema < SchemaV2 {\n\t\treturn ErrLegacySchema\n\t}\n\tif p.Pid <= 0 {\n\t\treturn ErrBadPid\n\t}\n\tif p.Port < 1 || p.Port > 65535 || (p.ControlPort != 0 && (p.ControlPort < 1 || p.ControlPort > 65535)) {\n\t\treturn ErrBadPort\n\t}\n\tif p.Kind != wantKind {\n\t\treturn ErrKindMismatch\n\t}\n\tif p.Birth == \"\" {","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dbproxy/pidfile/pidfile.go#L17-L53","documentation":"ErrKindMismatch means the pidfile's kind field does not match the expected kind of the component doing the validation, e.g. a 'dolt-backend' pidfile found where a 'db-proxy' pidfile is required. This prevents a backend process record from being mistaken for a proxy and vice versa.","triggerScenarios":"ValidateV2(wantKind) called with a wantKind (KindProxy or KindDoltBackend) that differs from the pidfile's recorded Kind; readAndDial/stopAndAcquire probing a pidfile belonging to another component.","commonSituations":"Configuration pointing a proxy client at a backend pidfile path; two components sharing a workspace directory; leftover pidfile from a differently-configured run.","solutions":["Point the caller at the correct pidfile path for the component kind","Delete the mismatched stale pidfile and restart the component","Check errors.Is(err, pidfile.ErrKindMismatch) and skip (not kill) the foreign record"],"exampleFix":"// before\nif err := pf.ValidateV2(pidfile.KindProxy); err != nil { return err }\n// after\nif err := pf.ValidateV2(pidfile.KindProxy); err != nil {\n    if errors.Is(err, pidfile.ErrKindMismatch) {\n        return nil // foreign pidfile: leave it alone\n    }\n    return err\n}","handlingStrategy":"type-guard","validationCode":"var pf pidfile.PidFile\njson.Unmarshal(data, &pf)\nif pf.Kind != pidfile.KindProxy { return fmt.Errorf(\"expected %s pidfile, got %s\", pidfile.KindProxy, pf.Kind) }","typeGuard":"func isKindMismatch(err error) bool { return errors.Is(err, pidfile.ErrKindMismatch) }","tryCatchPattern":"if err := pf.ValidateV2(wantKind); err != nil {\n    if errors.Is(err, pidfile.ErrKindMismatch) { return nil /* skip foreign record */ }\n    return err\n}","preventionTips":["Use distinct pidfile directories per component kind","Check pidfile Kind before operating on it","Avoid pointing multiple components at one workspace root"],"tags":["pidfile","configuration","kind-mismatch"],"backgroundTag":"pidfile-kind-mismatch","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}