gastownhall/beads · error

clear notion.view_url

Error message

clear notion.view_url: %w

What it means

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.

Solutions

  1. Inspect the wrapped cause for the underlying delete failure (lock, permissions, corruption).
  2. Ensure no other bd process holds the DB; retry after it exits.
  3. Check write permissions on the .beads data directory.
  4. As a workaround, overwrite the key with SetConfig instead of deleting it, then delete later.

Example fix

// before
if err := deleter.DeleteConfig(ctx, "notion.view_url"); err != nil {
    return fmt.Errorf("clear notion.view_url: %w", err)
}
// after
if err := setter.SetConfig(ctx, "notion.view_url", ""); err != nil {
    return fmt.Errorf("clear notion.view_url: %w", err)
}
Defensive patterns

Strategy: try-catch

Validate before calling

if deleter == nil {
    return errors.New("store does not support config deletion")
}
// ensure store writable before deleting
if err := setter.SetConfig(ctx, "notion.view_url", "probe"); err != nil {
    return fmt.Errorf("store not writable: %w", err)
}

Try / catch

if err := saveNotionTargetConfigWithWriter(ctx, setter, deleter, dsID, ""); err != nil {
    if strings.Contains(err.Error(), "clear notion.view_url") {
        // storage delete failed: check locks, permissions, retry
    }
    return err
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/b389dfef48de2e08. Report an issue: GitHub.

Appendix: source

Thrown at cmd/bd/notion.go:720

	}
	deleter, _ := storage.UnwrapStore(store).(notionConfigDeleter)
	return deleter
}

func saveNotionTargetConfigWithWriter(ctx context.Context, setter notionConfigSetter, deleter notionConfigDeleter, dataSourceID, viewURL string) error {
	if setter == nil {
		return fmt.Errorf("database not available")
	}
	if err := setter.SetConfig(ctx, "notion.data_source_id", strings.TrimSpace(dataSourceID)); err != nil {
		return fmt.Errorf("save notion.data_source_id: %w", err)
	}
	viewURL = strings.TrimSpace(viewURL)
	if viewURL == "" {
		if deleter == nil {
			return fmt.Errorf("store does not support config deletion")
		}
		if err := deleter.DeleteConfig(ctx, "notion.view_url"); err != nil {
			return fmt.Errorf("clear notion.view_url: %w", err)
		}
		return nil
	}
	if err := setter.SetConfig(ctx, "notion.view_url", viewURL); err != nil {
		return fmt.Errorf("save notion.view_url: %w", err)
	}
	return nil
}

func writeNotionJSON(cmd *cobra.Command, value interface{}) error {
	encoder := json.NewEncoder(cmd.OutOrStdout())
	encoder.SetIndent("", "  ")
	return encoder.Encode(value)
}

func firstNonEmpty(values ...string) string {
	for _, value := range values {
		if strings.TrimSpace(value) != "" {

View on GitHub (pinned to 71377f2769)