gastownhall/beads · error

parse archive page response: %w

Error message

parse archive page response: %w

What it means

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.

Source

Thrown at internal/notion/client.go:188

	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)
	RetrieveDatabase(ctx context.Context, databaseID string) (*Database, error)
}

type ResolvedDataSource struct {
	InputID      string
	DataSourceID string
	DataSource   *DataSource
	Database     *Database
	ViewURL      string
}

func ResolveDataSourceReference(ctx context.Context, client DataSourceResolver, ref string) (*ResolvedDataSource, error) {

View on GitHub (pinned to 71377f2769)

Solutions

  1. Inspect the raw body on failure to see what broke decoding.
  2. Upgrade the notion client library for current API compatibility.
  3. Verify the pinned Notion-Version header matches the library's expectations.
  4. 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).
Defensive patterns

Strategy: try-catch

Try / catch

page, err := client.ArchivePage(ctx, pageID, true)
if err != nil {
    if strings.Contains(err.Error(), "parse archive page response") {
        // confirm via re-fetch; the trash operation may have succeeded
    }
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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