{"record":{"id":"543355c33c60734d","repo":"gastownhall/beads","slug":"hosted-database-q-has-no-issue-prefix-provisio","errorCode":null,"errorMessage":"hosted database %q has no issue_prefix -- provisioning-contract violation; bd will not choose one for a hosted database (re-provision server-side, then re-run init)","messagePattern":"hosted database %q has no issue_prefix -- provisioning-contract violation; bd will not choose one for a hosted database \\(re-provision server-side, then re-run init\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/init.go","lineNumber":106,"sourceCode":"// existing value is adopted. A missing value is a provisioning-contract\n// violation — bd will not choose a prefix for a hosted database — but only when\n// the read genuinely succeeded and returned empty: a read error means we could\n// not consult the server, so it is surfaced as the transient failure it is\n// rather than misdiagnosed as an unprovisioned database.\n//\n// Whether the prefix may be WRITTEN is not decided here: that is the same\n// question as whether the substrate is unidentified, and issueops.Bootstrapper\n// answers it inside the transaction it writes in.\nfunc resolveInitIssuePrefix(gateway bool, existing, dbName, prefix string, readErr error) (value string, err error) {\n\tif existing != \"\" {\n\t\treturn \"\", nil\n\t}\n\tif gateway {\n\t\tif readErr != nil {\n\t\t\treturn \"\", fmt.Errorf(\n\t\t\t\t\"reading issue_prefix from hosted database %q: %w\", dbName, readErr)\n\t\t}\n\t\treturn \"\", fmt.Errorf(\n\t\t\t\"hosted database %q has no issue_prefix -- provisioning-contract violation; \"+\n\t\t\t\t\"bd will not choose one for a hosted database (re-provision server-side, then re-run init)\",\n\t\t\tdbName)\n\t}\n\treturn strings.ReplaceAll(prefix, \".\", \"_\"), nil\n}\n\n// resolveInitProjectID decides init's project identity by reconciling the local\n// metadata.json id (localID; \"\" when none is set yet) with the _project_id read\n// from the database (adoptedFromDB; \"\" when absent or not consulted). readErr is\n// the error, if any, from that read. changed reports whether the resolved id\n// differs from localID, so the caller can surface the reconciliation.\n//\n// Gateway: the hosted database's identity is server-authoritative, so an adopted\n// server id always wins and is reconciled onto local even when localID is already\n// set. A re-init or orchestrator-preseeded workspace must not keep a stale local\n// id: for Gateway specifically, init's CreateIfMissing:true open still skips the\n// storage identity verifier (store.go verifyProjectIdentity/newServerMode — see","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/init.go#L88-L124","documentation":"In gateway mode the issue_prefix must be provisioned server-side before init. If the read succeeds but the hosted database has no issue_prefix, init refuses to invent one — this is flagged as a provisioning-contract violation, with the database name in the message.","triggerScenarios":"`bd init` with a gateway connection against a hosted database whose issue_prefix config is empty/missing after a successful read — i.e. the server-side provisioning step never ran or was wiped.","commonSituations":"Database created out-of-band (manual SQL/API creation) without the provisioning flow; a host-side wipe/reset that dropped the config; pointing bd at the wrong database name; an old backend version that predates prefix provisioning.","solutions":["Re-provision the database server-side (per the error: re-provision, then re-run init) so issue_prefix exists","Verify you're pointing at the right hosted database name (--database / connection config)","If you're the host operator, set the prefix in the hosted DB's config table: issue_prefix = <prefix>","Confirm the hosted backend version supports prefix provisioning"],"exampleFix":"// before: gateway DB missing prefix\nbd init  # fails: hosted database \"xyz\" has no issue_prefix -- provisioning-contract violation\n// after: re-provision server-side (or have the host set issue_prefix), then\nbd init","handlingStrategy":"validation","validationCode":"// Before gateway init, verify the hosted DB carries a prefix\nprefix, err := readConfigFromHostedDB(dbName, \"issue_prefix\")\nif err != nil { return err }\nif strings.TrimSpace(prefix) == \"\" {\n    return fmt.Errorf(\"hosted DB %s is unprovisioned: re-provision server-side first\", dbName)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always provision hosted databases through the server-side flow, not manual creation","Confirm the --database name matches the provisioned DB before init","After any host-side reset, re-provision before clients run init","Never let bd choose a prefix for hosted DBs — set it deliberately server-side"],"tags":["gateway","hosted-database","provisioning","issue-prefix"],"backgroundTag":"provisioning-contract-violation","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}