gastownhall/beads · error

parse update page response

Error message

parse update page response: %w

What it means

UpdatePage PATCHes /pages/{id} with a properties object and unmarshals the reply into Page; this error wraps unmarshal failure of that reply. It means the PATCH succeeded at the HTTP level but the body could not be decoded into Page.

Solutions

  1. Log the raw response body to identify the offending JSON shape.
  2. Update the notion client library so Page/property types match the current API.
  3. Pin Notion-Version to the version the library targets.
  4. As a workaround, send properties via UpdatePage but read results via QueryDataSource if only query responses decode reliably.
Defensive patterns

Strategy: try-catch

Try / catch

page, err := client.UpdatePage(ctx, pageID, props)
if err != nil {
    if strings.Contains(err.Error(), "parse update page response") {
        // PATCH likely succeeded; re-fetch or tolerate decode failure
    }
    return err
}

Prevention

When it happens

Trigger: Calling Client.UpdatePage with properties whose response representation (e.g. newly added property types, changed rich-text or formula value shapes) does not fit the Page struct, or receiving a non-JSON 200 body from an intermediary.

Common situations: Updating pages that contain property types the library was never built to decode (Notion adds types over time); API version drift; gateway error pages served with 200.

Understand the failure class

Background: "failed to unmarshal" / json.Unmarshal errors: why parsing a response into a Go struct fails and how to fix it — this error's family across 23 libraries.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/1cb5ccd17f2255aa. Report an issue: GitHub.

Appendix: source

Thrown at internal/notion/client.go:176

	if err != nil {
		return nil, err
	}
	var page Page
	if err := json.Unmarshal(body, &page); err != nil {
		return nil, fmt.Errorf("parse create page response: %w", err)
	}
	return &page, nil
}

func (c *Client) UpdatePage(ctx context.Context, pageID string, properties map[string]interface{}) (*Page, error) {
	request := map[string]interface{}{"properties": properties}
	body, err := c.doRequest(ctx, http.MethodPatch, "/pages/"+url.PathEscape(pageID), request)
	if err != nil {
		return nil, err
	}
	var page Page
	if err := json.Unmarshal(body, &page); err != nil {
		return nil, fmt.Errorf("parse update page response: %w", err)
	}
	return &page, nil
}

func (c *Client) ArchivePage(ctx context.Context, pageID string, inTrash bool) (*Page, error) {
	body, err := c.doRequest(ctx, http.MethodPatch, "/pages/"+url.PathEscape(pageID), map[string]interface{}{"in_trash": inTrash})
	if err != nil {
		return nil, err
	}
	var page Page
	if err := json.Unmarshal(body, &page); err != nil {
		return nil, fmt.Errorf("parse archive page response: %w", err)
	}
	return &page, nil
}

type DataSourceResolver interface {
	RetrieveDataSource(ctx context.Context, dataSourceID string) (*DataSource, error)

View on GitHub (pinned to 71377f2769)