gastownhall/beads · error

save notion.data_source_id: %w

Error message

save notion.data_source_id: %w

What it means

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.

Source

Thrown at cmd/bd/notion.go:712

		return notionSetupResult{}, err
	}
	return result, nil
}

func notionConfigDeleteTarget() notionConfigDeleter {
	if store == nil {
		return nil
	}
	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 {

View on GitHub (pinned to 71377f2769)

Solutions

  1. Check the wrapped cause (%w chain) for the underlying storage error and fix that first (e.g. start Dolt, repair the DB).
  2. Verify a database is initialized: run 'bd doctor' or 'bd init' before notion init/connect.
  3. Check disk space and write permissions on the .beads directory.
  4. Retry the notion init/connect command after fixing storage.

Example fix

// before
bd notion init --data-source-id abc123   # fails if Dolt server is down
// after
bd doctor          # confirm DB reachable; start/repair Dolt
bd notion init --data-source-id abc123
Defensive patterns

Strategy: try-catch

Validate before calling

if store == nil {
    return errors.New("no database open; run bd init first")
}
if strings.TrimSpace(dataSourceID) == "" {
    return errors.New("dataSourceID is required")
}

Type guard

func storeReady(s interface{ SetConfig(context.Context, string, string) error }) bool { return s != nil }

Try / catch

if err := saveNotionTargetConfigWithWriter(ctx, setter, deleter, dsID, viewURL); err != nil {
    var storageErr error
    if errors.As(err, &storageErr) && strings.Contains(err.Error(), "save notion.data_source_id") {
        // inspect wrapped cause, check DB health, retry
    }
    return err
}

Prevention

When it happens

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

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

Related errors


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