{"record":{"id":"f9115ed2eddccfea","repo":"wtfutil/wtf","slug":"could-not-unmarshal-url-s-response-s-erro","errorCode":null,"errorMessage":"could not unmarshal url [%s] \n\t\tresponse [%s] error:%w","messagePattern":"could not unmarshal url \\[(.+?)\\] \n\t\tresponse \\[(.+?)\\] error:%w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/pocket/client.go","lineNumber":108,"sourceCode":"\n\tresp, err := http.DefaultClient.Do(request)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() { _ = resp.Body.Close() }()\n\n\tresponseBody, err := io.ReadAll(resp.Body)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\tif resp.StatusCode >= 400 {\n\t\treturn fmt.Errorf(`server responded with [%d]:%s,url:%s`, resp.StatusCode, responseBody, req.url)\n\t}\n\n\tif err := json.Unmarshal(responseBody, &result); err != nil {\n\t\treturn fmt.Errorf(\"could not unmarshal url [%s] \\n\\t\\tresponse [%s] error:%w\",\n\t\t\treq.url, responseBody, err)\n\t}\n\n\treturn nil\n\n}\n\ntype obtainRequestTokenRequest struct {\n\tConsumerKey string `json:\"consumer_key\"`\n\tRedirectURI string `json:\"redirect_uri\"`\n}\n\n// ObtainRequestToken get request token to be used in the auth workflow\nfunc (client *Client) ObtainRequestToken() (code string, err error) {\n\turl := fmt.Sprintf(\"%s/oauth/request\", client.baseURL)\n\trequestData := obtainRequestTokenRequest{ConsumerKey: client.consumerKey, RedirectURI: client.redirectURL}\n\n\tvar responseData map[string]string","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/pocket/client.go#L90-L126","documentation":"Raised in the Pocket client's request helper when json.Unmarshal fails on the API response body: Pocket returned a 2xx status, but the body is not the JSON shape the caller expected — empty body, HTML error page behind a proxy, or an unexpected schema.","triggerScenarios":"Thrown at modules/pocket/client.go:108 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Log/inspect the raw response body included in the error to see what was actually returned","Re-authenticate if the body indicates an auth-related payload mismatch","Check for proxies or captive portals returning HTML instead of JSON","Verify the Pocket API endpoint URL is current"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bb838c1ccb0f0f3223690df44afdec663d622881","analyzedAt":"2026-09-03T17:02:45.030Z","contentChangedAt":"2026-09-03T17:02:45.030Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}