{"record":{"id":"68ee032ddce3ef43","repo":"gastownhall/beads","slug":"project-identity-mismatch-refusing-to-connect-68ee03","errorCode":null,"errorMessage":"PROJECT IDENTITY MISMATCH — refusing to connect\n\n  Local project ID (metadata.json):  %s\n  Database %q project ID:            %s\n\nThe team server is serving a DIFFERENT project's database.\nThis can happen when:\n  - --database (or a --db name override) points at another project\n  - the configured dolt_database was repointed after 'bd init'\n  - the operator re-provisioned this database for another project\n\nCheck dolt_database in .beads/metadata.json and any --database/--db\noverride. 'bd init --team-server' re-adopts the provisioned identity\nand never writes to the shared database, so it is safe to re-run.","messagePattern":"PROJECT IDENTITY MISMATCH — refusing to connect\n\n  Local project ID \\(metadata\\.json\\):  %s\n  Database %q project ID:            %s\n\nThe team server is serving a DIFFERENT project's database\\.\nThis can happen when:\n  - --database \\(or a --db name override\\) points at another project\n  - the configured dolt_database was repointed after 'bd init'\n  - the operator re-provisioned this database for another project\n\nCheck dolt_database in \\.beads/metadata\\.json and any --database/--db\noverride\\. 'bd init --team-server' re-adopts the provisioned identity\nand never writes to the shared database, so it is safe to re-run\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/storage/uow/team_server_schema.go","lineNumber":82,"sourceCode":"\t// the metadata table exists and a failure here is a real fault, not the\n\t// legacy-database case verifyProjectIdentity tolerates.\n\tdbProjectID, err := issueops.GetMetadataInTx(ctx, conn, \"_project_id\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"uow: team-server identity check on database %q: %w\", database, err)\n\t}\n\t// Unlike verifyProjectIdentity, an absent stored identity is NOT tolerated\n\t// here. adoptTeamServerIdentity refuses to attach to a bts database that\n\t// has no metadata._project_id at all, so for a team-server database this\n\t// is an already-invalid state rather than a legacy one — and soft-skipping\n\t// it would mean deleting one row from the shared database silently\n\t// disables this guard for every client.\n\tif dbProjectID == \"\" {\n\t\treturn fmt.Errorf(\n\t\t\t\"uow: database %q has no project identity (metadata._project_id) — the schema is managed by beads-team-server; ask your operator to provision it with 'bts init' (or heal an older bts database with 'bts migrate')\",\n\t\t\tdatabase)\n\t}\n\tif dbProjectID != expectedProjectID {\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 %q project ID:            %s\\n\\n\"+\n\t\t\t\t\"The team server is serving a DIFFERENT project's database.\\n\"+\n\t\t\t\t\"This can happen when:\\n\"+\n\t\t\t\t\"  - --database (or a --db name override) points at another project\\n\"+\n\t\t\t\t\"  - the configured dolt_database was repointed after 'bd init'\\n\"+\n\t\t\t\t\"  - the operator re-provisioned this database for another project\\n\\n\"+\n\t\t\t\t\"Check dolt_database in .beads/metadata.json and any --database/--db\\n\"+\n\t\t\t\t\"override. 'bd init --team-server' re-adopts the provisioned identity\\n\"+\n\t\t\t\t\"and never writes to the shared database, so it is safe to re-run.\",\n\t\t\texpectedProjectID, database, dbProjectID)\n\t}\n\treturn nil\n}\n","sourceCodeStart":64,"sourceCodeEnd":98,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/uow/team_server_schema.go#L64-L98","documentation":"A hard refusal to connect because the database's stored project ID does not match the local project ID in .beads/metadata.json. The team server is serving a different project's database; writing would corrupt another project's data, so bd aborts with a diagnostic explaining the likely causes and the safe re-adoption path ('bd init --team-server').","triggerScenarios":"checkTeamServerIdentity compares dbProjectID (metadata._project_id in the database) against expectedProjectID (local metadata.json) and they differ during verifyTeamServerSchema.","commonSituations":"--database/--db override pointing at another project's database; dolt_database repointed in config after 'bd init'; operator re-provisioned the database for a different project; cloning a repo without regenerating local metadata against the right database.","solutions":["Check dolt_database in .beads/metadata.json and any --database/--db override; point back at your project's database","If you intend to adopt the provisioned database, re-run 'bd init --team-server' (read-only re-adoption, safe to re-run)","If the operator re-provisioned the database, coordinate re-initialization of local metadata","Do not edit _project_id manually in the shared database"],"exampleFix":"// before\nbd sync --database beads-other  # PROJECT IDENTITY MISMATCH\n// after\nbd init --team-server --database beads   # re-adopt correct provisioned identity\nbd sync --database beads","handlingStrategy":"validation","validationCode":"-- preflight: compare local vs database identity before any write\n# local:\njq -r .default_database .beads/metadata.json; cat .beads/metadata.json | grep -i project\n# database:\nSELECT value FROM metadata WHERE `key` = '_project_id';  -- must equal local project ID","typeGuard":"func isIdentityMismatch(err error) bool {\n  return err != nil && strings.Contains(err.Error(), \"PROJECT IDENTITY MISMATCH\")\n}","tryCatchPattern":"err := bdSync(ctx)\nif isIdentityMismatch(err) {\n  // never retry blindly — you may write to another project's database\n  return fmt.Errorf(\"fix --database/dolt_database or re-adopt with 'bd init --team-server': %w\", err)\n}","preventionTips":["Verify dolt_database in .beads/metadata.json after any config change","Avoid ad-hoc --database/--db overrides in scripts and CI","Re-run 'bd init --team-server' (safe, read-only) when switching provisioned databases","Treat this error as a stop sign: never work around it by editing _project_id"],"tags":["database","identity-mismatch","team-server","configuration"],"backgroundTag":"project-identity-mismatch","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}