{"record":{"id":"1141b09435bb135d","repo":"gastownhall/beads","slug":"parse-archive-page-response-w","errorCode":null,"errorMessage":"parse archive page response: %w","messagePattern":"parse archive page response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/notion/client.go","lineNumber":188,"sourceCode":"\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) {\n\tbody, err := c.doRequest(ctx, http.MethodPatch, \"/pages/\"+url.PathEscape(pageID), map[string]interface{}{\"in_trash\": inTrash})\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 archive page response: %w\", err)\n\t}\n\treturn &page, nil\n}\n\ntype DataSourceResolver interface {\n\tRetrieveDataSource(ctx context.Context, dataSourceID string) (*DataSource, error)\n\tRetrieveDatabase(ctx context.Context, databaseID string) (*Database, error)\n}\n\ntype ResolvedDataSource struct {\n\tInputID      string\n\tDataSourceID string\n\tDataSource   *DataSource\n\tDatabase     *Database\n\tViewURL      string\n}\n\nfunc ResolveDataSourceReference(ctx context.Context, client DataSourceResolver, ref string) (*ResolvedDataSource, error) {","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/notion/client.go#L170-L206","documentation":"ArchivePage PATCHes /pages/{id} with {\"in_trash\": inTrash} and unmarshals the response into Page; this error wraps an unmarshal failure on that response. The archive/trash operation reached the server, but the returned page JSON could not be decoded.","triggerScenarios":"Calling Client.ArchivePage when the response body deviates from the Page struct (schema drift, new property value shapes) or when an intermediary returns non-JSON content with a success status.","commonSituations":"Archiving pages in a database whose rows contain newer property types the library cannot decode; Notion API version change altering the archived-page response; corporate proxy interference.","solutions":["Inspect the raw body on failure to see what broke decoding.","Upgrade the notion client library for current API compatibility.","Verify the pinned Notion-Version header matches the library's expectations.","If decode keeps failing but the operation succeeds server-side, treat HTTP 200 as confirmation and decode into a minimal struct (id + in_trash only)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"page, err := client.ArchivePage(ctx, pageID, true)\nif err != nil {\n    if strings.Contains(err.Error(), \"parse archive page response\") {\n        // confirm via re-fetch; the trash operation may have succeeded\n    }\n    return err\n}","preventionTips":["Treat HTTP 200 as the success signal; decoding is secondary","Keep the library updated for API schema changes","Pin Notion-Version","Log raw bodies when decoding fails"],"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"}