{"record":{"id":"c4ebd1822617351b","repo":"gastownhall/beads","slug":"no-store-available-c4ebd1","errorCode":null,"errorMessage":"no store available","messagePattern":"no store available","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/federation.go","lineNumber":145,"sourceCode":"\n\t// Flags for sync\n\tfederationSyncCmd.Flags().StringVar(&federationPeer, \"peer\", \"\", \"Specific peer to sync with\")\n\tfederationSyncCmd.Flags().StringVar(&federationStrategy, \"strategy\", \"\", \"Conflict resolution strategy (ours|theirs)\")\n\n\t// Flags for status\n\tfederationStatusCmd.Flags().StringVar(&federationPeer, \"peer\", \"\", \"Specific peer to check\")\n\n\t// Flags for add-peer (SQL user authentication)\n\tfederationAddPeerCmd.Flags().StringVarP(&federationUser, \"user\", \"u\", \"\", \"SQL username for authentication\")\n\tfederationAddPeerCmd.Flags().StringVarP(&federationPassword, \"password\", \"p\", \"\", \"SQL password (prompted if --user set without --password)\")\n\tfederationAddPeerCmd.Flags().StringVar(&federationSov, \"sovereignty\", \"\", \"Sovereignty tier (T1, T2, T3, T4)\")\n\n\trootCmd.AddCommand(federationCmd)\n}\n\nfunc getFederatedStore() (storage.DoltStorage, error) {\n\tif store == nil {\n\t\treturn nil, fmt.Errorf(\"no store available\")\n\t}\n\treturn store, nil\n}\n\nfunc runFederationSync(cmd *cobra.Command, args []string) error {\n\tif usesProxiedServer() {\n\t\treturn HandleErrorRespectJSON(\"federation sync is not supported in proxied-server mode\")\n\t}\n\tevt := metrics.NewCommandEvent(\"federation-sync\")\n\tdefer func() {\n\t\tif c := metrics.Global(); c != nil {\n\t\t\tc.CloseEventAndAdd(evt)\n\t\t}\n\t}()\n\n\tctx := rootCtx\n\n\tds, err := getFederatedStore()","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/federation.go#L127-L163","documentation":"getFederatedStore returns the process-global `store` used by federation subcommands, and this error means that global was never initialized. In bd, the global store is set up by root command initialization (persistent pre-run) when a database is opened; if federation sync/status runs before that setup — or in a mode that skips store creation — there is no storage handle to operate on.","triggerScenarios":"Running `bd federation sync` or `bd federation status` in a context where the root command's persistent store initialization did not run (e.g. store left nil due to an earlier silent init failure, or the command being invoked through a path that bypasses PersistentPreRun).","commonSituations":"Invoking federation commands programmatically without going through root command execution; an earlier database-open failure that left `store` nil without aborting the command; unusual environments (embedded/proxied server mode) where store creation is skipped.","solutions":["Run the federation command through the normal `bd` CLI so root initialization opens the store first","Fix the earlier store-initialization failure (check for prior connection errors — often the DB path or Dolt server config is wrong)","Verify the working directory contains an initialized beads database (`.beads/`) before running federation commands","If invoking programmatically, ensure the same PersistentPreRun/initialization path that sets the global `store` executes first"],"exampleFix":"// before: federation command assumes store exists\nstore, err := getFederatedStore() // errors: no store available\n// after: ensure initialization happened before using the store\nif err := rootCmd.PersistentPreRunE(federationCmd, args); err != nil { return err }\nstore, err := getFederatedStore()","handlingStrategy":"type-guard","validationCode":"// before invoking federation subcommands programmatically, confirm the store is open\nif store == nil {\n    return fmt.Errorf(\"run via the bd CLI (or initialize the store) before federation commands\")\n}","typeGuard":"func hasFederatedStore() bool { return store != nil }","tryCatchPattern":"st, err := getFederatedStore()\nif err != nil {\n    return fmt.Errorf(\"federation requires an open database; run `bd` from a repo with .beads/: %w\", err)\n}","preventionTips":["Invoke federation commands via the normal `bd` CLI so root PersistentPreRun opens the store","Fix any earlier store-open failure — a nil store is often the downstream symptom of a failed DB open","Run from a directory with an initialized `.beads/` database","When scripting, don't call runFederation* directly; exercise the root command"],"tags":["go","federation","initialization","cli"],"backgroundTag":"store-not-initialized","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}