gastownhall/beads · error
notion client is nil
Error message
notion client is nil
What it means
ResolveDataSourceReference requires a non-nil DataSourceResolver to call RetrieveDataSource/RetrieveDatabase. If the client argument is nil it fails fast with this error instead of panicking on a nil interface call.
Source
Thrown at internal/notion/client.go:208
return &page, nil
}
type DataSourceResolver interface {
RetrieveDataSource(ctx context.Context, dataSourceID string) (*DataSource, error)
RetrieveDatabase(ctx context.Context, databaseID string) (*Database, error)
}
type ResolvedDataSource struct {
InputID string
DataSourceID string
DataSource *DataSource
Database *Database
ViewURL string
}
func ResolveDataSourceReference(ctx context.Context, client DataSourceResolver, ref string) (*ResolvedDataSource, error) {
if client == nil {
return nil, fmt.Errorf("notion client is nil")
}
identifier := ExtractNotionIdentifier(ref)
if identifier == "" {
return nil, fmt.Errorf("could not extract a Notion ID from %q", ref)
}
if ds, err := client.RetrieveDataSource(ctx, identifier); err == nil {
return &ResolvedDataSource{
InputID: identifier,
DataSourceID: ds.ID,
DataSource: ds,
ViewURL: strings.TrimSpace(ref),
}, nil
} else {
db, dbErr := client.RetrieveDatabase(ctx, identifier)
if dbErr != nil {
return nil, fmt.Errorf("resolve %q as data source: %w; as database: %v", ref, err, dbErr)
}
if len(db.DataSources) == 0 || strings.TrimSpace(db.DataSources[0].ID) == "" {View on GitHub (pinned to 71377f2769)
Solutions
- Construct the client with notion.NewClient(token) before resolving references and propagate any constructor error.
- Guard the call site: skip resolution (or return a config error) when Notion is not configured.
- Check that the variable holding the client is typed as an interface, not a typed-nil pointer like (*notion.Client)(nil).
- Log client initialization failures where they happen instead of deferring to the resolve call.
Example fix
// before
resolved, err := notion.ResolveDataSourceReference(ctx, client, viewURL) // client may be nil
// after
if client == nil {
return nil, fmt.Errorf("notion integration not configured: missing client")
}
resolved, err := notion.ResolveDataSourceReference(ctx, client, viewURL) Defensive patterns
Strategy: validation
Validate before calling
if client == nil {
return fmt.Errorf("notion client not configured")
} Prevention
- Handle constructor errors immediately; never pass a possibly-nil client onward
- Distinguish 'integration not configured' from runtime failures at the call site
- Avoid typed-nil interface values ((*notion.Client)(nil))
- Initialize clients once at startup and fail fast
When it happens
Trigger: Calling notion.ResolveDataSourceReference with a nil client or a nil-typed interface value — e.g. the client was never constructed because config/token loading failed earlier and the nil was passed through.
Common situations: Constructor errors swallowed upstream so the code proceeds with a nil *notion.Client; optional integration wiring where Notion is unconfigured but the resolver is still invoked; test fixtures forgetting to initialize the client.
Related errors
- could not extract a Notion ID from %q
- Notion token not configured
- multiple .doltcfg directories detected
- dolt directory is required
- httpapi: a configured role fires this workspace's hooks; thi
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/17f75ec740b3debc.
Report an issue: GitHub.