{"record":{"id":"6057b1c35e75d845","repo":"gastownhall/beads","slug":"parse-current-user-response-w","errorCode":null,"errorMessage":"parse current user response: %w","messagePattern":"parse current user response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/notion/client.go","lineNumber":59,"sourceCode":"\tclone := *c\n\tclone.HTTPClient = httpClient\n\treturn &clone\n}\n\nfunc (c *Client) WithBaseURL(baseURL string) *Client {\n\tclone := *c\n\tclone.BaseURL = strings.TrimSuffix(baseURL, \"/\")\n\treturn &clone\n}\n\nfunc (c *Client) GetCurrentUser(ctx context.Context) (*User, error) {\n\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)","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/notion/client.go#L41-L77","documentation":"GetCurrentUser calls the Notion /users/me endpoint and unmarshals the JSON body into a User. If the response body isn't valid JSON or doesn't match the User shape, the json error is wrapped with this message.","triggerScenarios":"json.Unmarshal(body, &user) fails after a successful doRequest: malformed JSON, HTML error page returned with 200, or unexpected field types.","commonSituations":"Proxy/captive portal returning HTML; wrong base URL pointing at a non-Notion service; Notion API change; truncated response.","solutions":["Print/log the raw response body to see what was actually returned.","Verify the client's base URL and that no proxy intercepts requests to api.notion.com.","Check the notion library version against the current Notion API and update the User struct if the schema changed."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func isNotionParseError(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"parse current user response\")\n}","tryCatchPattern":"user, err := client.GetCurrentUser(ctx)\nif err != nil {\n    var jsonErr *json.UnmarshalTypeError\n    if errors.As(err, &jsonErr) {\n        return fmt.Errorf(\"unexpected Notion response, check API version: %w\", err)\n    }\n    return err\n}","preventionTips":["Pin the Notion API version header","Bypass/inspect proxies when testing","Log raw response bodies on failure"],"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"}