{"record":{"id":"7a622ee73f7df830","repo":"gastownhall/beads","slug":"project-identity-mismatch-refusing-to-connect","errorCode":null,"errorMessage":"PROJECT IDENTITY MISMATCH — refusing to connect\n\n  Local project ID (metadata.json):  %s\n  Database project ID:               %s\n\nThis means the Dolt server is serving a DIFFERENT project's database.\nThis can happen when:\n  - Another project's server is running on the same port\n  - The server restarted with a different data directory\n\nTo diagnose: bd dolt status\nDo NOT run 'bd init' — your data likely exists, just on a different server.","messagePattern":"PROJECT IDENTITY MISMATCH — refusing to connect\n\n  Local project ID \\(metadata\\.json\\):  (.+?)\n  Database project ID:               (.+?)\n\nThis means the Dolt server is serving a DIFFERENT project's database\\.\nThis can happen when:\n  - Another project's server is running on the same port\n  - The server restarted with a different data directory\n\nTo diagnose: bd dolt status\nDo NOT run 'bd init' — your data likely exists, just on a different server\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/storage/dolt/store.go","lineNumber":2124,"sourceCode":"\n\t// Load local project ID from metadata.json\n\tmetaCfg, err := configfile.Load(beadsDir)\n\tif err != nil || metaCfg == nil {\n\t\treturn nil // no local config — skip verification\n\t}\n\tlocalID := metaCfg.ProjectID\n\tif localID == \"\" {\n\t\treturn nil // old-style metadata.json without project_id — skip\n\t}\n\n\t// Read project ID from database metadata table\n\tdbID, err := s.GetMetadata(ctx, \"_project_id\")\n\tif err != nil || dbID == \"\" {\n\t\treturn nil // old database without project_id — skip\n\t}\n\n\tif localID != dbID {\n\t\treturn fmt.Errorf(\n\t\t\t\"PROJECT IDENTITY MISMATCH — refusing to connect\\n\\n\"+\n\t\t\t\t\"  Local project ID (metadata.json):  %s\\n\"+\n\t\t\t\t\"  Database project ID:               %s\\n\\n\"+\n\t\t\t\t\"This means the Dolt server is serving a DIFFERENT project's database.\\n\"+\n\t\t\t\t\"This can happen when:\\n\"+\n\t\t\t\t\"  - Another project's server is running on the same port\\n\"+\n\t\t\t\t\"  - The server restarted with a different data directory\\n\\n\"+\n\t\t\t\t\"To diagnose: bd dolt status\\n\"+\n\t\t\t\t\"Do NOT run 'bd init' — your data likely exists, just on a different server.\",\n\t\t\tlocalID, dbID)\n\t}\n\treturn nil\n}\n\nfunc (s *DoltStore) verifyGlobalProjectIdentity(ctx context.Context, beadsDir string) error {\n\tif beadsDir == \"\" {\n\t\treturn nil\n\t}","sourceCodeStart":2106,"sourceCodeEnd":2142,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/store.go#L2106-L2142","documentation":"This is a safety guard against connecting to a database belonging to a different project. The store compares the local metadata.json project ID with the database's stored project ID and refuses the connection on mismatch, preventing cross-project data corruption. It includes diagnostic guidance instead of a plain error.","triggerScenarios":"Calling any open/connect path that runs verifyProjectIdentity where s.GetMetadata(ctx, \"_project_id\") returns a non-empty ID different from the local metadata.json project ID.","commonSituations":"Another project's Dolt server is running on the same port; the Dolt server restarted pointing at a different data directory; two projects share a port by mistake.","solutions":["Run bd dolt status to identify which project the server is actually serving","Stop the wrong server and start the correct project's server on that port","Verify the server's data directory matches this project (.beads)","Do NOT run bd init — the data likely exists on another server"],"exampleFix":"// before (wrong project's server on port)\nbd dolt start-server  # uses wrong data dir\n// after\nbd dolt status  # confirm serving project\nbd dolt start-server --data-dir /path/to/this/project/.beads","handlingStrategy":"validation","validationCode":"localID := readProjectIDFromMetadata(\".beads/metadata.json\")\ndbID, err := store.GetMetadata(ctx, \"_project_id\")\nif err == nil && dbID != \"\" && dbID != localID {\n    return fmt.Errorf(\"project mismatch: local=%s db=%s\", localID, dbID)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"PROJECT IDENTITY MISMATCH\") {\n        // run bd dolt status; fix server/port before retrying\n    }\n    return err\n}","preventionTips":["Never share one Dolt server port between projects","Pin server data-dir per project (.beads)","Check bd dolt status after any server restart","Never run bd init to 'fix' identity errors"],"tags":["configuration","identity","dolt","project-mismatch"],"backgroundTag":"project-identity-mismatch","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}