{"record":{"id":"99520f6f75c19f30","repo":"gastownhall/beads","slug":"notion-authentication-is-not-configured-set-notio","errorCode":null,"errorMessage":"Notion authentication is not configured. Set notion.token with 'bd config set notion.token <token>', or export NOTION_TOKEN","messagePattern":"Notion authentication is not configured\\. Set notion\\.token with 'bd config set notion\\.token <token>', or export NOTION_TOKEN","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/notion.go","lineNumber":208,"sourceCode":"\tif store != nil {\n\t\treturn notion.ResolveAuth(ctx, store)\n\t}\n\tif dbPath != \"\" {\n\t\ttempStore, err := openReadOnlyStoreForDBPath(ctx, dbPath)\n\t\tif err == nil {\n\t\t\tdefer func() { _ = tempStore.Close() }()\n\t\t\treturn notion.ResolveAuth(ctx, tempStore)\n\t\t}\n\t}\n\tif token := strings.TrimSpace(os.Getenv(\"NOTION_TOKEN\")); token != \"\" {\n\t\treturn &notion.ResolvedAuth{Token: token, Source: notion.AuthSourceEnv}, nil\n\t}\n\treturn nil, nil\n}\n\nfunc validateNotionConfig(cfg notionConfig, auth *notion.ResolvedAuth) error {\n\tif auth == nil || strings.TrimSpace(auth.Token) == \"\" {\n\t\treturn fmt.Errorf(\"Notion authentication is not configured. Set notion.token with 'bd config set notion.token <token>', or export NOTION_TOKEN\")\n\t}\n\tif cfg.DataSourceID == \"\" {\n\t\treturn 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\")\n\t}\n\treturn nil\n}\n\nfunc validateNotionToken(auth *notion.ResolvedAuth) error {\n\tif auth == nil || strings.TrimSpace(auth.Token) == \"\" {\n\t\treturn fmt.Errorf(\"Notion authentication is not configured. Set notion.token with 'bd config set notion.token <token>', or export NOTION_TOKEN\")\n\t}\n\treturn nil\n}\n\nfunc maskNotionAuth(auth *notion.ResolvedAuth) string {\n\tif auth == nil || strings.TrimSpace(auth.Token) == \"\" {\n\t\treturn \"(not set)\"\n\t}","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/notion.go#L190-L226","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run `bd config set notion.token <token>` to persist the token.","Or export NOTION_TOKEN in the current shell: `export NOTION_TOKEN=secret` and retry.","In CI, add NOTION_TOKEN as a secret/env var on the job.","Verify with `bd notion status` which runs the same validation."],"exampleFix":"// before\nbd notion sync\n// Error: Notion authentication is not configured...\n\n// after\nexport NOTION_TOKEN=ntn_xxx\nbd notion sync","handlingStrategy":"validation","validationCode":"token := os.Getenv(\"NOTION_TOKEN\")\nif token == \"\" {\n    return errors.New(\"set NOTION_TOKEN or run: bd config set notion.token <token>\")\n}","typeGuard":"func hasNotionAuth(auth *notion.ResolvedAuth) bool {\n    return auth != nil && strings.TrimSpace(auth.Token) != \"\"\n}","tryCatchPattern":"if err := runNotionSync(cmd, args); err != nil {\n    if strings.Contains(err.Error(), \"Notion authentication is not configured\") {\n        // surface setup instructions to the user instead of a stack trace\n    }\n    return err\n}","preventionTips":["Export NOTION_TOKEN in your shell profile so it persists across sessions","In CI, wire NOTION_TOKEN as a secret env var on the job","Run `bd notion status` as a preflight before push/pull scripts","Avoid sudo/wrappers that strip environment variables"],"tags":["go","notion","auth","config"],"backgroundTag":"missing-env-var","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}