{"record":{"id":"aee6638cb592fdb4","repo":"gastownhall/beads","slug":"parse-data-source-response-w","errorCode":null,"errorMessage":"parse data source response: %w","messagePattern":"parse data source response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/notion/client.go","lineNumber":71,"sourceCode":"\tbody, err := c.doRequest(ctx, http.MethodGet, \"/users/me\", nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar user User\n\tif err := json.Unmarshal(body, &user); err != nil {\n\t\treturn nil, fmt.Errorf(\"parse current user response: %w\", err)\n\t}\n\treturn &user, nil\n}\n\nfunc (c *Client) RetrieveDataSource(ctx context.Context, dataSourceID string) (*DataSource, error) {\n\tbody, err := c.doRequest(ctx, http.MethodGet, \"/data_sources/\"+url.PathEscape(dataSourceID), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar ds DataSource\n\tif err := json.Unmarshal(body, &ds); err != nil {\n\t\treturn nil, fmt.Errorf(\"parse data source response: %w\", err)\n\t}\n\treturn &ds, nil\n}\n\nfunc (c *Client) RetrieveDatabase(ctx context.Context, databaseID string) (*Database, error) {\n\tbody, err := c.doRequest(ctx, http.MethodGet, \"/databases/\"+url.PathEscape(databaseID), nil)\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 database response: %w\", err)\n\t}\n\treturn &db, nil\n}\n\nfunc (c *Client) CreateDatabase(ctx context.Context, parentPageID, title string) (*Database, error) {\n\tparentPageID = strings.TrimSpace(parentPageID)","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/notion/client.go#L53-L89","documentation":"RetrieveDataSource fetches a Notion data source by ID and unmarshals into DataSource. A body that can't be parsed into that struct produces this wrapped error.","triggerScenarios":"GET /data_sources/{id} returns 200 with a body that fails json.Unmarshal into DataSource: unexpected schema or non-JSON payload.","commonSituations":"Data source ID typo'd such that another endpoint responds; API version drift changing the data_source schema; intercepted response from a proxy.","solutions":["Log the raw body to inspect the unexpected payload.","Confirm the dataSourceID is a valid Notion data source ID.","Update the client/DataSource struct to match your Notion API version."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func isNotionParseError(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"parse data source response\")\n}","tryCatchPattern":"ds, err := client.RetrieveDataSource(ctx, id)\nif err != nil {\n    if strings.Contains(err.Error(), \"parse data source response\") {\n        return fmt.Errorf(\"check ID and API version: %w\", err)\n    }\n    return err\n}","preventionTips":["Validate IDs against the correct endpoint type","Pin the API version","Log raw bodies for diagnosis"],"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"}