gastownhall/beads · error

notion.data_source_id is not configured. Run 'bd notion init

Error message

notion.data_source_id is not configured. Run 'bd notion init --parent <page-id>' or 'bd notion connect --url <notion-url>', or set it directly via bd config set notion.data_source_id <id> or NOTION_DATA_SOURCE_ID

What it means

After auth passes, validateNotionConfig requires the configured Notion data source ID — the database table bd syncs with. Without it, sync commands cannot know where to write. The error lists every remediation path: `bd notion init`, `bd notion connect`, direct config, or the NOTION_DATA_SOURCE_ID env var.

Source

Thrown at cmd/bd/notion.go:211

	if dbPath != "" {
		tempStore, err := openReadOnlyStoreForDBPath(ctx, dbPath)
		if err == nil {
			defer func() { _ = tempStore.Close() }()
			return notion.ResolveAuth(ctx, tempStore)
		}
	}
	if token := strings.TrimSpace(os.Getenv("NOTION_TOKEN")); token != "" {
		return &notion.ResolvedAuth{Token: token, Source: notion.AuthSourceEnv}, nil
	}
	return nil, nil
}

func validateNotionConfig(cfg notionConfig, auth *notion.ResolvedAuth) error {
	if auth == nil || strings.TrimSpace(auth.Token) == "" {
		return fmt.Errorf("Notion authentication is not configured. Set notion.token with 'bd config set notion.token <token>', or export NOTION_TOKEN")
	}
	if cfg.DataSourceID == "" {
		return fmt.Errorf("notion.data_source_id is not configured. Run 'bd notion init --parent <page-id>' or 'bd notion connect --url <notion-url>', or set it directly via bd config set notion.data_source_id <id> or NOTION_DATA_SOURCE_ID")
	}
	return nil
}

func validateNotionToken(auth *notion.ResolvedAuth) error {
	if auth == nil || strings.TrimSpace(auth.Token) == "" {
		return fmt.Errorf("Notion authentication is not configured. Set notion.token with 'bd config set notion.token <token>', or export NOTION_TOKEN")
	}
	return nil
}

func maskNotionAuth(auth *notion.ResolvedAuth) string {
	if auth == nil || strings.TrimSpace(auth.Token) == "" {
		return "(not set)"
	}
	token := auth.Token
	if len(token) <= 4 {
		return "****"

View on GitHub (pinned to 71377f2769)

Solutions

  1. Run `bd notion init --parent <page-id>` to create and configure a new database.
  2. Or run `bd notion connect --url <notion-url>` to attach an existing database.
  3. Or set it directly: `bd config set notion.data_source_id <id>` or export NOTION_DATA_SOURCE_ID.
  4. Verify with `bd notion status`.

Example fix

// before
bd notion pull
// Error: notion.data_source_id is not configured...

// after
bd notion connect --url https://notion.so/workspace/<db-id>
bd notion pull
Defensive patterns

Strategy: validation

Validate before calling

if os.Getenv("NOTION_DATA_SOURCE_ID") == "" {
    if v, _ := exec.Command("bd", "config", "get", "notion.data_source_id").Output(); len(strings.TrimSpace(string(v))) == 0 {
        return errors.New("run `bd notion init --parent <page-id>` or `bd notion connect --url <url>` first")
    }
}

Type guard

func hasDataSourceID(cfg notionConfig) bool {
    return strings.TrimSpace(cfg.DataSourceID) != ""
}

Try / catch

if err := runNotionSync(cmd, args); err != nil {
    if strings.Contains(err.Error(), "data_source_id is not configured") {
        // run init/connect automatically or prompt the user
    }
    return err
}

Prevention

When it happens

Trigger: Running `bd notion status|sync|push|pull` with a valid token but notion.data_source_id empty in bd config and NOTION_DATA_SOURCE_ID unset — i.e., init/connect was never run or the config was wiped.

Common situations: Token configured but init step skipped; switching machines where only the token was exported via env; config database reset; data source deleted in Notion and config cleaned.

Related errors


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