{"record":{"id":"bbc6026297add2df","repo":"gastownhall/beads","slug":"loading-storage-metadata-w-bbc602","errorCode":null,"errorMessage":"loading storage metadata: %w","messagePattern":"loading storage metadata: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"beads_nocgo.go","lineNumber":22,"sourceCode":"\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/steveyegge/beads/internal/configfile\"\n\t\"github.com/steveyegge/beads/internal/storage/backends\"\n\t\"github.com/steveyegge/beads/internal/storage/dolt\"\n)\n\n// OpenBestAvailable opens a beads database using the best available backend\n// for the given .beads directory. In non-CGO builds, only Dolt server mode is\n// supported; embedded Dolt returns an error directing the user to server mode.\n//\n// beadsDir is the path to the .beads directory.\nfunc OpenBestAvailable(ctx context.Context, beadsDir string) (Storage, error) {\n\tcfg, err := configfile.Load(beadsDir)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"loading storage metadata: %w\", err)\n\t}\n\tif cfg == nil {\n\t\tcfg = configfile.DefaultConfig()\n\t}\n\tif !configfile.IsSupportedBackend(cfg.Backend) {\n\t\treturn nil, configuredBackendUnavailable(cfg.Backend)\n\t}\n\n\t// Dispatch to a registered extension backend before any Dolt path, mirroring\n\t// the CLI store factories so SDK callers get the backend they registered\n\t// instead of the embedded-Dolt-requires-CGO error.\n\tif backend, ok := backends.Lookup(cfg.GetBackend()); ok {\n\t\treturn backend.Open(ctx, beadsDir)\n\t}\n\n\tif cfg.IsDoltServerMode() {\n\t\tstore, err := dolt.NewFromConfig(ctx, beadsDir)\n\t\tif err != nil {","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/beads_nocgo.go#L4-L40","documentation":"The no-CGO build of OpenBestAvailable wraps configfile.Load failures identically to the CGO build: 'loading storage metadata: %w'. The storage metadata file in .beads could not be loaded, so backend selection cannot proceed. The root cause (missing/unreadable/corrupt metadata) is always available via the wrapped error.","triggerScenarios":"Calling OpenBestAvailable(ctx, beadsDir) in a pure-Go (CGO_ENABLED=0) build when configfile.Load on the .beads directory metadata returns an error.","commonSituations":"Deploying the pure-Go bd binary against a .beads directory created by another tool; truncated or hand-edited metadata file; read-only mounts or permission-denied after containerization.","solutions":["Read the wrapped cause to distinguish parse vs IO errors","Regenerate metadata with bd init or restore it from version control","Verify the process can read the .beads directory (permissions, mount flags)"],"exampleFix":"// before\nstore, err := beads.OpenBestAvailable(ctx, \".beads\")\n// after\nstore, err := beads.OpenBestAvailable(ctx, \".beads\")\nif err != nil {\n    log.Fatalf(\"cannot load .beads metadata: %v\", err) // includes wrapped cause\n}","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(filepath.Join(beadsDir)); err != nil {\n    return fmt.Errorf(\"beads dir missing; run bd init: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"store, err := beads.OpenBestAvailable(ctx, dir)\nif err != nil {\n    log.Fatalf(\"storage metadata load failed: %v\", err)\n}","preventionTips":["Verify the pure-Go binary is compatible with the repo's configured backend","Never hand-edit .beads metadata without validating YAML","Restore metadata from git before opening storage"],"tags":["go","storage","config-load","nocgo"],"backgroundTag":"storage-metadata-load-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}