gastownhall/beads · error

Notion authentication is not configured. Set notion.token wi

Error message

Notion authentication is not configured. Set notion.token with 'bd config set notion.token <token>', or export NOTION_TOKEN

What it means

validateNotionConfig performs the first gate for Notion sync/status/push/pull commands: it requires resolved Notion auth (a token). If auth is nil or the token is empty/whitespace, it returns this actionable error telling the user exactly how to configure the token via bd config or the NOTION_TOKEN environment variable.

Source

Thrown at cmd/bd/notion.go:208

	if store != nil {
		return notion.ResolveAuth(ctx, store)
	}
	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)"
	}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Run `bd config set notion.token <token>` to persist the token.
  2. Or export NOTION_TOKEN in the current shell: `export NOTION_TOKEN=secret` and retry.
  3. In CI, add NOTION_TOKEN as a secret/env var on the job.
  4. Verify with `bd notion status` which runs the same validation.

Example fix

// before
bd notion sync
// Error: Notion authentication is not configured...

// after
export NOTION_TOKEN=ntn_xxx
bd notion sync
Defensive patterns

Strategy: validation

Validate before calling

token := os.Getenv("NOTION_TOKEN")
if token == "" {
    return errors.New("set NOTION_TOKEN or run: bd config set notion.token <token>")
}

Type guard

func hasNotionAuth(auth *notion.ResolvedAuth) bool {
    return auth != nil && strings.TrimSpace(auth.Token) != ""
}

Try / catch

if err := runNotionSync(cmd, args); err != nil {
    if strings.Contains(err.Error(), "Notion authentication is not configured") {
        // surface setup instructions to the user instead of a stack trace
    }
    return err
}

Prevention

When it happens

Trigger: Running `bd notion status|sync|push|pull` when no token was set with `bd config set notion.token` and the NOTION_TOKEN env var is unset or empty/blank.

Common situations: Fresh machine without setup; token exported only in a different shell profile/session; CI environment missing the NOTION_TOKEN secret; token set to whitespace; using `sudo` which drops env vars.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


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