{"record":{"id":"b389dfef48de2e08","repo":"gastownhall/beads","slug":"clear-notion-view-url-w","errorCode":null,"errorMessage":"clear notion.view_url: %w","messagePattern":"clear notion\\.view_url: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/notion.go","lineNumber":720,"sourceCode":"\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 {\n\tencoder := json.NewEncoder(cmd.OutOrStdout())\n\tencoder.SetIndent(\"\", \"  \")\n\treturn encoder.Encode(value)\n}\n\nfunc firstNonEmpty(values ...string) string {\n\tfor _, value := range values {\n\t\tif strings.TrimSpace(value) != \"\" {","sourceCodeStart":702,"sourceCodeEnd":738,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/notion.go#L702-L738","documentation":"When clearing the Notion view URL, saveNotionTargetConfigWithWriter calls deleter.DeleteConfig(ctx, \"notion.view_url\"). If that storage delete fails, the error is wrapped as 'clear notion.view_url: %w'. It means the config key could not be removed from the store.","triggerScenarios":"deleter.DeleteConfig(ctx, \"notion.view_url\") returns an error during bd notion init/connect when viewURL is empty — storage-level failure deleting the config row (DB locked, corrupted, permission denied).","commonSituations":"Clearing the Notion view URL while the Dolt DB is offline/locked, the .beads directory is read-only, or a race with another bd process writing config.","solutions":["Inspect the wrapped cause for the underlying delete failure (lock, permissions, corruption).","Ensure no other bd process holds the DB; retry after it exits.","Check write permissions on the .beads data directory.","As a workaround, overwrite the key with SetConfig instead of deleting it, then delete later."],"exampleFix":"// before\nif err := deleter.DeleteConfig(ctx, \"notion.view_url\"); err != nil {\n    return fmt.Errorf(\"clear notion.view_url: %w\", err)\n}\n// after\nif err := setter.SetConfig(ctx, \"notion.view_url\", \"\"); err != nil {\n    return fmt.Errorf(\"clear notion.view_url: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"if deleter == nil {\n    return errors.New(\"store does not support config deletion\")\n}\n// ensure store writable before deleting\nif err := setter.SetConfig(ctx, \"notion.view_url\", \"probe\"); err != nil {\n    return fmt.Errorf(\"store not writable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := saveNotionTargetConfigWithWriter(ctx, setter, deleter, dsID, \"\"); err != nil {\n    if strings.Contains(err.Error(), \"clear notion.view_url\") {\n        // storage delete failed: check locks, permissions, retry\n    }\n    return err\n}","preventionTips":["Ensure no concurrent bd process locks the DB","Keep .beads writable by the running user","Overwrite with SetConfig as a delete fallback","Inspect the wrapped cause with errors.As before retrying"],"tags":["go","config","notion","storage"],"backgroundTag":"config-delete-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}