{"record":{"id":"1e73b6cbd50b14ed","repo":"gastownhall/beads","slug":"hosted-database-q-has-no-provisioned-project-iden","errorCode":null,"errorMessage":"hosted database %q has no provisioned project identity (_project_id) -- provisioning-contract violation; bd will not mint an identity for a hosted database","messagePattern":"hosted database %q has no provisioned project identity \\(_project_id\\) -- provisioning-contract violation; bd will not mint an identity for a hosted database","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/init.go","lineNumber":149,"sourceCode":"// A missing server id is a provisioning-contract violation bd will not mint\n// over — even when a local id already exists — and a read error is surfaced as\n// the transient failure it is, so a flaky connection is not misdiagnosed as an\n// unprovisioned database.\n//\n// Non-gateway (legacy, unchanged): a non-empty localID is kept as-is (readErr\n// ignored, exactly as before); otherwise an adopted id wins (another rig already\n// chose it; minting a new one would break cross-project verification), else a\n// fresh identity is generated.\nfunc resolveInitProjectID(gateway bool, localID, adoptedFromDB, dbName string, readErr error) (value string, changed bool, err error) {\n\tif gateway {\n\t\tif adoptedFromDB != \"\" {\n\t\t\treturn adoptedFromDB, adoptedFromDB != localID, nil\n\t\t}\n\t\tif readErr != nil {\n\t\t\treturn \"\", false, fmt.Errorf(\n\t\t\t\t\"reading project identity (_project_id) from hosted database %q: %w\", dbName, readErr)\n\t\t}\n\t\treturn \"\", false, fmt.Errorf(\n\t\t\t\"hosted database %q has no provisioned project identity (_project_id) -- \"+\n\t\t\t\t\"provisioning-contract violation; bd will not mint an identity for a hosted database\",\n\t\t\tdbName)\n\t}\n\tif localID != \"\" {\n\t\treturn localID, false, nil\n\t}\n\tif adoptedFromDB != \"\" {\n\t\treturn adoptedFromDB, true, nil\n\t}\n\treturn configfile.GenerateProjectID(), true, nil\n}\n\n// shouldConsultInitProjectID reports whether init must read _project_id from the\n// database before resolving the local identity.\n//\n// Gateway: always — the hosted server owns the identity, so init reconciles it on\n// every run, including a re-init or preseeded metadata.json that already carries a","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/init.go#L131-L167","documentation":"In gateway mode, if the hosted database reads successfully but contains no provisioned _project_id, init refuses to mint an identity — minting locally would diverge across clones and cause PROJECT IDENTITY MISMATCH on later opens. This is flagged as a provisioning-contract violation.","triggerScenarios":"`bd init` in gateway mode where the _project_id read succeeds but returns empty (adoptedFromDB == \"\", readErr == nil) — the hosted DB was never provisioned with a project identity.","commonSituations":"Database created manually/out-of-band without provisioning; host-side reset dropped _project_id; pointing at the wrong database name; legacy backend predating identity provisioning. Doing `bd doctor --fix` here is dangerous: whichever clone runs it first backfills, and others then hard-fail on open.","solutions":["Re-provision the database server-side so _project_id exists, then re-run `bd init`","Verify the --database/connection targets the correct provisioned hosted DB","Have the host operator set _project_id in the hosted DB deliberately","Do NOT run `bd doctor --fix` from multiple clones to backfill — settle identity deliberately from the clone that should win"],"exampleFix":"// before: gateway DB without _project_id\nbd init  # fails: hosted database \"xyz\" has no provisioned project identity (_project_id)\n// after: host re-provisions server-side; then\nbd init","handlingStrategy":"validation","validationCode":"// Before gateway init, verify the hosted DB has a project identity\npid, err := readConfigFromHostedDB(dbName, \"_project_id\")\nif err != nil { return err }\nif strings.TrimSpace(pid) == \"\" {\n    return fmt.Errorf(\"hosted DB %s lacks _project_id: re-provision server-side\", dbName)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provision hosted DBs server-side (identity included) before client init","Never backfill identity via `bd doctor --fix` from multiple clones — settle which clone wins first","Confirm the target database name before init","Treat a missing _project_id as a server-side defect, not something bd should mint over"],"tags":["gateway","hosted-database","provisioning","project-id","identity-mismatch"],"backgroundTag":"provisioning-contract-violation","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}