{"record":{"id":"589efe8568c533de","repo":"gastownhall/beads","slug":"save-notion-data-source-id-w","errorCode":null,"errorMessage":"save notion.data_source_id: %w","messagePattern":"save notion\\.data_source_id: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/notion.go","lineNumber":712,"sourceCode":"\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\n}\n\nfunc writeNotionJSON(cmd *cobra.Command, value interface{}) error {","sourceCodeStart":694,"sourceCodeEnd":730,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/notion.go#L694-L730","documentation":"saveNotionTargetConfigWithWriter persists the Notion data source ID into config storage via the setter's SetConfig. When the underlying store write fails, the error is wrapped as 'save notion.data_source_id: %w'. It signals the Notion integration target was not saved and the store may be unavailable, read-only, or erroring.","triggerScenarios":"setter.SetConfig(ctx, \"notion.data_source_id\", ...) returns an error during bd notion init/connect (or any anonymous caller) — e.g. the Dolt store is closed, the DB is corrupted/locked, or the config write fails at the storage layer.","commonSituations":"Running 'bd notion init' or 'bd notion connect' without a working database (missing .beads dir, Dolt daemon down), disk-full or permission errors on the beads data directory, or a store implementation that rejects the config key.","solutions":["Check the wrapped cause (%w chain) for the underlying storage error and fix that first (e.g. start Dolt, repair the DB).","Verify a database is initialized: run 'bd doctor' or 'bd init' before notion init/connect.","Check disk space and write permissions on the .beads directory.","Retry the notion init/connect command after fixing storage."],"exampleFix":"// before\nbd notion init --data-source-id abc123   # fails if Dolt server is down\n// after\nbd doctor          # confirm DB reachable; start/repair Dolt\nbd notion init --data-source-id abc123","handlingStrategy":"try-catch","validationCode":"if store == nil {\n    return errors.New(\"no database open; run bd init first\")\n}\nif strings.TrimSpace(dataSourceID) == \"\" {\n    return errors.New(\"dataSourceID is required\")\n}","typeGuard":"func storeReady(s interface{ SetConfig(context.Context, string, string) error }) bool { return s != nil }","tryCatchPattern":"if err := saveNotionTargetConfigWithWriter(ctx, setter, deleter, dsID, viewURL); err != nil {\n    var storageErr error\n    if errors.As(err, &storageErr) && strings.Contains(err.Error(), \"save notion.data_source_id\") {\n        // inspect wrapped cause, check DB health, retry\n    }\n    return err\n}","preventionTips":["Run bd doctor to confirm the store is healthy before notion init/connect","Initialize the beads DB before configuring Notion","Monitor disk space and permissions on .beads","Always check errors.Is/errors.As on the wrapped cause"],"tags":["go","config","notion","storage"],"backgroundTag":"config-save-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}