{"record":{"id":"74848a619f16d36b","repo":"gastownhall/beads","slug":"database-not-available","errorCode":null,"errorMessage":"database not available","messagePattern":"database not available","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/notion.go","lineNumber":709,"sourceCode":"\t\tresult.DatabaseID = strings.TrimSpace(resolved.Database.ID)\n\t}\n\tif err := saveNotionTargetConfigWithWriter(ctx, setter, deleter, result.DataSourceID, result.ViewURL); err != nil {\n\t\treturn notionSetupResult{}, err\n\t}\n\treturn result, nil\n}\n\nfunc notionConfigDeleteTarget() notionConfigDeleter {\n\tif store == nil {\n\t\treturn nil\n\t}\n\tdeleter, _ := storage.UnwrapStore(store).(notionConfigDeleter)\n\treturn deleter\n}\n\nfunc saveNotionTargetConfigWithWriter(ctx context.Context, setter notionConfigSetter, deleter notionConfigDeleter, dataSourceID, viewURL string) error {\n\tif setter == nil {\n\t\treturn fmt.Errorf(\"database not available\")\n\t}\n\tif err := setter.SetConfig(ctx, \"notion.data_source_id\", strings.TrimSpace(dataSourceID)); err != nil {\n\t\treturn fmt.Errorf(\"save notion.data_source_id: %w\", err)\n\t}\n\tviewURL = strings.TrimSpace(viewURL)\n\tif viewURL == \"\" {\n\t\tif deleter == nil {\n\t\t\treturn fmt.Errorf(\"store does not support config deletion\")\n\t\t}\n\t\tif err := deleter.DeleteConfig(ctx, \"notion.view_url\"); err != nil {\n\t\t\treturn fmt.Errorf(\"clear notion.view_url: %w\", err)\n\t\t}\n\t\treturn nil\n\t}\n\tif err := setter.SetConfig(ctx, \"notion.view_url\", viewURL); err != nil {\n\t\treturn fmt.Errorf(\"save notion.view_url: %w\", err)\n\t}\n\treturn nil","sourceCodeStart":691,"sourceCodeEnd":727,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/notion.go#L691-L727","documentation":"saveNotionTargetConfigWithWriter persists notion.data_source_id (and view URL) through a config setter. In proxied-server mode the setter is resolved from the storage backend; if the store is missing or does not implement the notionConfigSetter interface, setter is nil and bd cannot persist the target, so it fails with 'database not available' rather than silently dropping the config.","triggerScenarios":"Called from runNotionInitAfterValidation or runNotionConnectAfterValidation (or an inline closure) when the storage.UnwrapStore(store) result is nil or doesn't implement SetConfig, so no setter could be constructed.","commonSituations":"Running notion init/connect without an open/local database (e.g. outside a beads-initialized repo); proxied-server mode where the backing database isn't attached; embedded usage passing a store that doesn't implement the config-setter capability.","solutions":["Initialize the beads database in the workspace first (`bd init`) and re-run the notion command.","Ensure the proxied server is running with its database attached, then retry.","Run the command in the repository root where the .beads database exists.","If embedding, pass a store that implements the config SetConfig/Deleter capability."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Ensure a beads database exists before notion setup\nif _, err := os.Stat(\".beads\"); err != nil {\n    return errors.New(\"run `bd init` in this workspace before bd notion init/connect\")\n}","typeGuard":null,"tryCatchPattern":"if err := runNotionConnect(cmd, args); err != nil {\n    if strings.Contains(err.Error(), \"database not available\") {\n        // initialize/open the database or attach it to the proxied server, then retry\n    }\n    return err\n}","preventionTips":["Run `bd init` before any notion setup in a fresh workspace","Execute notion commands from the repository root, not a subdirectory or bare environment","In proxied-server mode, verify the server has its database attached","When embedding, supply a store implementing the config setter/deleter capability"],"tags":["go","notion","storage","config"],"backgroundTag":"database-not-available","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}