{"record":{"id":"f645aad9763b2b7c","repo":"gastownhall/beads","slug":"load-s-w-no-storage-database-was-opened-or-mod","errorCode":null,"errorMessage":"load %s: %w; no storage database was opened or modified (storage mode unknown; data commands refuse to fall back to the embedded store)","messagePattern":"load (.+?): %w; no storage database was opened or modified \\(storage mode unknown; data commands refuse to fall back to the embedded store\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/main.go","lineNumber":469,"sourceCode":"\tfmt.Fprintln(os.Stderr, \"  To stay embedded: unset BEADS_DOLT_SHARED_SERVER (or remove dolt.shared-server from config.yaml).\")\n}\n\n// loadServerModeFromBeadsDir loads the storage mode (embedded vs server vs\n// proxied-server) from the given beads directory's metadata.json so that\n// usesSQLServer() and usesProxiedServer() return the correct values.\n//\n// A metadata.json that exists but cannot be loaded is a hard error: treating\n// it like an absent file silently flips server-mode deployments onto the\n// embedded store, where every query answers from an empty relic with exit 0\n// (false-empty). Absent metadata.json (cfg == nil) keeps the fresh-repo\n// embedded default.\nfunc loadServerModeFromBeadsDir(beadsDir string) error {\n\tif beadsDir == \"\" {\n\t\treturn nil\n\t}\n\tcfg, err := configfile.LoadForDiscovery(beadsDir)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"load %s: %w; no storage database was opened or modified (storage mode unknown; data commands refuse to fall back to the embedded store)\", configfile.ConfigPath(beadsDir), err)\n\t}\n\t// Absent metadata.json keeps the fresh-repo embedded default unless\n\t// env/config.yaml supply a remote host (GH#3545) — inference must not\n\t// depend on metadata existing.\n\tcfg = normalizeLoadedConfig(cfg)\n\twarnSharedServerEmbeddedMismatch(cfg)\n\tpsm := cfg.IsDoltProxiedServerMode()\n\tsm := cfg.IsDoltServerMode()\n\t// GH#2946: shared-server override for stale metadata.json (no-db commands)\n\tif !sm && !psm && doltserver.IsSharedServerMode() {\n\t\tsm = true\n\t}\n\tserverMode = sm\n\tproxiedServerMode = psm\n\tif cmdCtx != nil {\n\t\tcmdCtx.ServerMode = sm\n\t\tcmdCtx.ProxiedServerMode = psm\n\t}","sourceCodeStart":451,"sourceCodeEnd":487,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/main.go#L451-L487","documentation":"At startup bd must learn whether it should run in server mode by loading config/metadata.json from the .beads directory. If configfile.LoadForDiscovery fails (e.g. corrupt or unreadable metadata.json), bd aborts with this error and explicitly does NOT fall back to the embedded store, because storage mode would be unknown and data commands could write to the wrong backend.","triggerScenarios":"Running any data command where <beadsDir>/config/metadata.json exists but is malformed JSON, has invalid fields, or cannot be read due to permissions; detected by loadServerModeFromBeadsDir during command-context preparation.","commonSituations":"A crashed sync or interrupted `bd dolt pull` left metadata.json half-written; manual editing broke JSON syntax; disk-full during a previous write; file ownership/permission issues after user switch.","solutions":["Inspect and repair config/metadata.json (validate JSON, restore from backup or git history)","Delete the corrupt metadata.json only if you accept fresh-repo embedded defaults (re-infer from env/config.yaml)","Check file permissions on the .beads directory","Run `bd doctor` after repair to confirm storage mode resolves correctly"],"exampleFix":"// before\n$ cat .beads/config/metadata.json\n{\"server_remote\": \"https://...\",,}   # trailing comma, invalid JSON\n// after\n{\"server_remote\": \"https://...\"}\n$ bd doctor","handlingStrategy":"validation","validationCode":"var meta map[string]any\nraw, err := os.ReadFile(filepath.Join(beadsDir, \"config\", \"metadata.json\"))\nif err != nil {\n    return err\n}\nif err := json.Unmarshal(raw, &meta); err != nil {\n    return fmt.Errorf(\"metadata.json corrupt: %w\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never hand-edit metadata.json while commands may be running","Keep metadata.json under version control or backed up","Avoid killing processes mid-`bd dolt pull`","Validate JSON after any manual edit"],"tags":["config","startup","metadata"],"backgroundTag":"corrupt-metadata-json","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}