{"record":{"id":"d9aead34e2d0ccf7","repo":"gastownhall/beads","slug":"parse-create-database-response-w","errorCode":null,"errorMessage":"parse create database response: %w","messagePattern":"parse create database response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/notion/client.go","lineNumber":115,"sourceCode":"\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},\n\t\t\"title\":     richTextRequest(title),\n\t\t\"is_inline\": false,\n\t\t\"initial_data_source\": map[string]interface{}{\n\t\t\t\"title\":      richTextRequest(title),\n\t\t\t\"properties\": BuildInitialDataSourceProperties(),\n\t\t},\n\t}\n\tbody, err := c.doRequest(ctx, http.MethodPost, \"/databases\", request)\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 create database response: %w\", err)\n\t}\n\treturn &db, nil\n}\n\nfunc (c *Client) QueryDataSource(ctx context.Context, dataSourceID string) ([]Page, error) {\n\tvar pages []Page\n\tvar cursor string\n\tfor pageNum := 0; pageNum < maxQueryPages; pageNum++ {\n\t\trequest := map[string]interface{}{\n\t\t\t\"page_size\":   maxPageSize,\n\t\t\t\"result_type\": \"page\",\n\t\t}\n\t\tif cursor != \"\" {\n\t\t\trequest[\"start_cursor\"] = cursor\n\t\t}\n\n\t\tbody, err := c.doRequest(ctx, http.MethodPost, \"/data_sources/\"+url.PathEscape(dataSourceID)+\"/query\", request)\n\t\tif err != nil {","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/notion/client.go#L97-L133","documentation":"CreateDatabase POSTs to /databases and unmarshals the response into Database. If the returned body can't be parsed into that struct, the json error is wrapped with this message.","triggerScenarios":"POST /databases returns 200/201 with a body failing json.Unmarshal into Database: schema drift, non-JSON error payload, or partial response.","commonSituations":"Notion API version mismatch; proxy interference; response shape changed for databases created via data-source parents.","solutions":["Log the raw response body to see what Notion returned.","Pin/update the Notion API version header and update the Database struct accordingly.","Retry after confirming no proxy rewrites responses."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func isNotionParseError(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"parse create database response\")\n}","tryCatchPattern":"db, err := client.CreateDatabase(ctx, parentPageID, title)\nif err != nil {\n    var jsonErr *json.UnmarshalTypeError\n    if errors.As(err, &jsonErr) {\n        return fmt.Errorf(\"unexpected create-database response: %w\", err)\n    }\n    return err\n}","preventionTips":["Pin the Notion API version","Log raw response bodies on failure","Update Database struct when API schema changes"],"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"}