wtfutil/wtf · error
could not unmarshal url [%s] response [%s] error:%w
Error message
could not unmarshal url [%s] response [%s] error:%w
What it means
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.
Source
Thrown at modules/pocket/client.go:108
resp, err := http.DefaultClient.Do(request)
if err != nil {
return err
}
defer func() { _ = resp.Body.Close() }()
responseBody, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
if resp.StatusCode >= 400 {
return fmt.Errorf(`server responded with [%d]:%s,url:%s`, resp.StatusCode, responseBody, req.url)
}
if err := json.Unmarshal(responseBody, &result); err != nil {
return fmt.Errorf("could not unmarshal url [%s] \n\t\tresponse [%s] error:%w",
req.url, responseBody, err)
}
return nil
}
type obtainRequestTokenRequest struct {
ConsumerKey string `json:"consumer_key"`
RedirectURI string `json:"redirect_uri"`
}
// ObtainRequestToken get request token to be used in the auth workflow
func (client *Client) ObtainRequestToken() (code string, err error) {
url := fmt.Sprintf("%s/oauth/request", client.baseURL)
requestData := obtainRequestTokenRequest{ConsumerKey: client.consumerKey, RedirectURI: client.redirectURL}
var responseData map[string]stringView on GitHub (pinned to bb838c1ccb)
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
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at modules/pocket/client.go:108 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of wtfutil/wtf@bb838c1ccb (2026-09-03).
Data as JSON: /api/errors/f9115ed2eddccfea.
Report an issue: GitHub.