gastownhall/beads · error
parse database response: %w
Error message
parse database response: %w
What it means
RetrieveDatabase fetches a Notion database by ID and unmarshals into Database. A body that can't be parsed into that struct produces this wrapped error.
Source
Thrown at internal/notion/client.go:83
body, err := c.doRequest(ctx, http.MethodGet, "/data_sources/"+url.PathEscape(dataSourceID), nil)
if err != nil {
return nil, err
}
var ds DataSource
if err := json.Unmarshal(body, &ds); err != nil {
return nil, fmt.Errorf("parse data source response: %w", err)
}
return &ds, nil
}
func (c *Client) RetrieveDatabase(ctx context.Context, databaseID string) (*Database, error) {
body, err := c.doRequest(ctx, http.MethodGet, "/databases/"+url.PathEscape(databaseID), nil)
if err != nil {
return nil, err
}
var db Database
if err := json.Unmarshal(body, &db); err != nil {
return nil, fmt.Errorf("parse database response: %w", err)
}
return &db, nil
}
func (c *Client) CreateDatabase(ctx context.Context, parentPageID, title string) (*Database, error) {
parentPageID = strings.TrimSpace(parentPageID)
if parentPageID == "" {
return nil, fmt.Errorf("parent page ID is required")
}
title = strings.TrimSpace(title)
if title == "" {
title = DefaultDatabaseTitle
}
request := map[string]interface{}{
"parent": map[string]interface{}{
"type": "page_id",
"page_id": parentPageID,
},View on GitHub (pinned to 71377f2769)
Solutions
- Verify the ID is a database ID, not a data source ID; use RetrieveDataSource for data sources.
- Log the raw response body to identify the mismatch.
- Update the Database struct / client for your Notion API version.
Defensive patterns
Strategy: type-guard
Type guard
func isNotionParseError(err error) bool {
return err != nil && strings.Contains(err.Error(), "parse database response")
} Try / catch
db, err := client.RetrieveDatabase(ctx, id)
if err != nil {
if strings.Contains(err.Error(), "parse database response") {
return fmt.Errorf("verify this ID is a database, not a data source: %w", err)
}
return err
} Prevention
- Distinguish database IDs from data source IDs
- Pin the API version
- Log raw bodies on failure
When it happens
Trigger: GET /databases/{id} returns 200 with a body that fails json.Unmarshal into Database.
Common situations: Passing a data_source ID to the databases endpoint (or vice versa); Notion API schema drift; proxy returning non-JSON content.
Related errors
- parse current user response: %w
- parse data source response: %w
- parse create database response: %w
- parse data source query response: %w
- parse create page response: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/0a69b9eec21a75c7.
Report an issue: GitHub.