{"record":{"id":"d45778cf2c6b8c0e","repo":"gastownhall/beads","slug":"parse-create-page-response-w","errorCode":null,"errorMessage":"parse create page response: %w","messagePattern":"parse create page response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/notion/client.go","lineNumber":163,"sourceCode":"\t}\n\treturn nil, fmt.Errorf(\"query pagination exceeded %d pages\", maxQueryPages)\n}\n\nfunc (c *Client) CreatePage(ctx context.Context, dataSourceID string, properties map[string]interface{}) (*Page, error) {\n\trequest := map[string]interface{}{\n\t\t\"parent\": map[string]interface{}{\n\t\t\t\"type\":           \"data_source_id\",\n\t\t\t\"data_source_id\": dataSourceID,\n\t\t},\n\t\t\"properties\": properties,\n\t}\n\tbody, err := c.doRequest(ctx, http.MethodPost, \"/pages\", request)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar page Page\n\tif err := json.Unmarshal(body, &page); err != nil {\n\t\treturn nil, fmt.Errorf(\"parse create page response: %w\", err)\n\t}\n\treturn &page, nil\n}\n\nfunc (c *Client) UpdatePage(ctx context.Context, pageID string, properties map[string]interface{}) (*Page, error) {\n\trequest := map[string]interface{}{\"properties\": properties}\n\tbody, err := c.doRequest(ctx, http.MethodPatch, \"/pages/\"+url.PathEscape(pageID), request)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar page Page\n\tif err := json.Unmarshal(body, &page); err != nil {\n\t\treturn nil, fmt.Errorf(\"parse update page response: %w\", err)\n\t}\n\treturn &page, nil\n}\n\nfunc (c *Client) ArchivePage(ctx context.Context, pageID string, inTrash bool) (*Page, error) {","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/notion/client.go#L145-L181","documentation":"CreatePage POSTs to /pages and unmarshals the response into a Page struct; this error wraps unmarshal failure. The API accepted the request (HTTP layer passed) but the returned page JSON does not fit the Page struct.","triggerScenarios":"Calling Client.CreatePage when the response body is not valid JSON or its shape (properties, parent, id fields) no longer matches the Page struct — typically after a Notion API schema change or a non-JSON body from an intermediary.","commonSituations":"Notion changing page property value shapes (e.g. rich_text arrays, new property types) so Unmarshal errors on typed fields; misconfigured API gateway returning HTML; stale library version against a newer API.","solutions":["Log the raw body on failure to see whether it is JSON and where the shape differs.","Upgrade the notion client library so Page matches the current API schema.","Verify the Notion-Version header is pinned to a version compatible with the structs.","If only the ID is needed, consider decoding into a minimal struct with just json:\"id\" to tolerate unknown property shapes."],"exampleFix":"// before\nvar page Page\nif err := json.Unmarshal(body, &page); err != nil {\n    return nil, fmt.Errorf(\"parse create page response: %w\", err)\n}\n// after\nvar page Page\nif err := json.Unmarshal(body, &page); err != nil {\n    return nil, fmt.Errorf(\"parse create page response: %w (body: %.200s)\", err, body)\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"page, err := client.CreatePage(ctx, dsID, props)\nif err != nil {\n    if strings.Contains(err.Error(), \"parse create page response\") {\n        // check whether the page was actually created (re-query) before retrying\n    }\n    return err\n}","preventionTips":["Pin Notion-Version to the version the library targets","Update the library when Notion changes page property shapes","On failure, verify whether the page was created server-side before retrying","Log raw response bodies for decode failures"],"tags":["notion","json","api","response-parsing"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}