{"record":{"id":"0a69b9eec21a75c7","repo":"gastownhall/beads","slug":"parse-database-response-w","errorCode":null,"errorMessage":"parse database response: %w","messagePattern":"parse database response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/notion/client.go","lineNumber":83,"sourceCode":"\tbody, err := c.doRequest(ctx, http.MethodGet, \"/data_sources/\"+url.PathEscape(dataSourceID), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar ds DataSource\n\tif err := json.Unmarshal(body, &ds); err != nil {\n\t\treturn nil, fmt.Errorf(\"parse data source response: %w\", err)\n\t}\n\treturn &ds, nil\n}\n\nfunc (c *Client) RetrieveDatabase(ctx context.Context, databaseID string) (*Database, error) {\n\tbody, err := c.doRequest(ctx, http.MethodGet, \"/databases/\"+url.PathEscape(databaseID), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar db Database\n\tif err := json.Unmarshal(body, &db); err != nil {\n\t\treturn nil, fmt.Errorf(\"parse database response: %w\", err)\n\t}\n\treturn &db, nil\n}\n\nfunc (c *Client) CreateDatabase(ctx context.Context, parentPageID, title string) (*Database, error) {\n\tparentPageID = strings.TrimSpace(parentPageID)\n\tif parentPageID == \"\" {\n\t\treturn nil, fmt.Errorf(\"parent page ID is required\")\n\t}\n\ttitle = strings.TrimSpace(title)\n\tif title == \"\" {\n\t\ttitle = DefaultDatabaseTitle\n\t}\n\trequest := map[string]interface{}{\n\t\t\"parent\": map[string]interface{}{\n\t\t\t\"type\":    \"page_id\",\n\t\t\t\"page_id\": parentPageID,\n\t\t},","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/notion/client.go#L65-L101","documentation":"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.","triggerScenarios":"GET /databases/{id} returns 200 with a body that fails json.Unmarshal into Database.","commonSituations":"Passing a data_source ID to the databases endpoint (or vice versa); Notion API schema drift; proxy returning non-JSON content.","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."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func isNotionParseError(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"parse database response\")\n}","tryCatchPattern":"db, err := client.RetrieveDatabase(ctx, id)\nif err != nil {\n    if strings.Contains(err.Error(), \"parse database response\") {\n        return fmt.Errorf(\"verify this ID is a database, not a data source: %w\", err)\n    }\n    return err\n}","preventionTips":["Distinguish database IDs from data source IDs","Pin the API version","Log raw bodies on failure"],"tags":["notion","json","api"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}