{"record":{"id":"bef3c8c3bf93a0f6","repo":"gastownhall/beads","slug":"failed-to-record-the-workspace-identity-v","errorCode":null,"errorMessage":"failed to record the workspace identity: %v","messagePattern":"failed to record the workspace identity: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/init.go","lineNumber":319,"sourceCode":"\t\t// half-bootstrapped state the role refuses to complete later.\n\t\tif existing, err := configfile.Load(beadsDir); err == nil && existing != nil {\n\t\t\tprojectID = existing.ProjectID\n\t\t}\n\t\tif projectID == \"\" {\n\t\t\tprojectID = configfile.GenerateProjectID()\n\t\t}\n\t}\n\n\tbootstrapper, err := store.Bootstrapper()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to reach the workspace identity: %v\", err)\n\t}\n\t_, err = bootstrapper.Bootstrap(ctx, issueops.BootstrapRequest{\n\t\tPrefix:    prefix,\n\t\tProjectID: projectID,\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to record the workspace identity: %v\", err)\n\t}\n\treturn nil\n}\n\nvar initCmd = &cobra.Command{\n\tUse:           \"init\",\n\tGroupID:       \"setup\",\n\tSilenceUsage:  true,\n\tSilenceErrors: true,\n\tShort:         \"Initialize bd in the current directory\",\n\tLong: `Initialize bd in the current directory by creating a .beads/ directory\nand its storage (a Dolt database by default). Optionally specify a custom issue prefix.\n\nDolt is the default and only supported storage backend, with full version\ncontrol (history, branching, sync).\n\nUse --database to specify an existing server database name, overriding the\ndefault prefix-based naming. This is useful when an external tool (e.g. an orchestrator)","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/init.go#L301-L337","documentation":"This error wraps any failure from the workspace-identity bootstrap step during `bd init`. The bootstrapper records the workspace identity (prefix + project ID) in the newly initialized workspace; if that write fails, init aborts with this message and the underlying cause appended via %v.","triggerScenarios":"Running `bd init` when bootstrapper.Bootstrap(ctx, issueops.BootstrapRequest{Prefix, ProjectID}) returns an error — e.g. the underlying database write fails, the workspace identity record already exists with conflicting values, or storage is unreachable/locked.","commonSituations":"Initializing a workspace in a directory with a corrupt or partially-created .beads database; permission problems on the data directory; concurrent bd processes holding a lock during init; re-running init over an existing workspace with a different prefix/project ID.","solutions":["Read the wrapped cause after 'failed to record the workspace identity:' — it names the real failure","Check the .beads data directory permissions and disk space","If re-initializing an existing workspace, back up and remove the old identity/state or use matching prefix/project ID values","Retry when no other bd process is running (lock contention)"],"exampleFix":"// before\nbd init  # fails: failed to record the workspace identity: database is locked\n// after\n# close other bd sessions / remove stale lock, then re-run\nbd init","handlingStrategy":"try-catch","validationCode":"# before init\n[ -w .beads ] || { echo 'data dir not writable'; exit 1; }\npgrep -f 'bd ' && echo 'other bd processes may hold locks'","typeGuard":null,"tryCatchPattern":"err := bootstrapper.Bootstrap(ctx, req)\nif err != nil {\n    return fmt.Errorf(\"failed to record the workspace identity: %w\", err)\n}\n// at CLI boundary: match on the prefix string and print the wrapped cause to the user","preventionTips":["Run init in a clean directory or back up .beads first","Avoid running concurrent bd commands during init","Check disk space and directory permissions before init","Read the wrapped cause (%v suffix) before guessing at fixes"],"tags":["init","bootstrap","workspace-identity","storage"],"backgroundTag":"bootstrap-write-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}