gastownhall/beads · error

database not available

Error message

database not available

What it means

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.

Source

Thrown at cmd/bd/notion.go:709

		result.DatabaseID = strings.TrimSpace(resolved.Database.ID)
	}
	if err := saveNotionTargetConfigWithWriter(ctx, setter, deleter, result.DataSourceID, result.ViewURL); err != nil {
		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

View on GitHub (pinned to 71377f2769)

Solutions

  1. Initialize the beads database in the workspace first (`bd init`) and re-run the notion command.
  2. Ensure the proxied server is running with its database attached, then retry.
  3. Run the command in the repository root where the .beads database exists.
  4. If embedding, pass a store that implements the config SetConfig/Deleter capability.
Defensive patterns

Strategy: validation

Validate before calling

// Ensure a beads database exists before notion setup
if _, err := os.Stat(".beads"); err != nil {
    return errors.New("run `bd init` in this workspace before bd notion init/connect")
}

Try / catch

if err := runNotionConnect(cmd, args); err != nil {
    if strings.Contains(err.Error(), "database not available") {
        // initialize/open the database or attach it to the proxied server, then retry
    }
    return err
}

Prevention

When it happens

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

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

Related errors


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