wtfutil/wtf · error
executing request: %w
Error message
executing request: %w
What it means
FetchArticles wraps errors from c.httpClient.Do(req) as 'executing request'. This is a transport-level failure: DNS resolution, TCP connect, TLS handshake, timeout, or a canceled context. The request was built fine, but it never got an HTTP response.
Source
Thrown at modules/devto/client.go:69
if username != "" {
q.Set("username", username)
}
if state != "" {
q.Set("state", state)
}
if perPage > 0 {
q.Set("per_page", fmt.Sprintf("%d", perPage))
}
u.RawQuery = q.Encode()
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
if err != nil {
return nil, fmt.Errorf("creating request: %w", err)
}
resp, err := c.httpClient.Do(req)
if err != nil {
return nil, fmt.Errorf("executing request: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("unexpected status %d from DEV.to API", resp.StatusCode)
}
var articles []Article
if err := json.NewDecoder(resp.Body).Decode(&articles); err != nil {
return nil, fmt.Errorf("decoding response: %w", err)
}
return articles, nil
}
View on GitHub (pinned to bb838c1ccb)
Solutions
- Check basic connectivity to https://dev.to (curl https://dev.to/api/articles)
- Configure HTTP(S)_PROXY env vars if behind a corporate proxy
- Increase the http.Client timeout or verify ctx deadlines aren't too aggressive
- Retry with backoff on transient network errors
Example fix
// before
client := NewClient("")
client.httpClient = &http.Client{} // no timeout; hangs then fails
// after
client.httpClient = &http.Client{Timeout: 10 * time.Second}
articles, err := client.FetchArticles(ctx, tag, user, state, perPage)
if err != nil {
return fmt.Errorf("devto fetch: %w", err)
} Defensive patterns
Strategy: retry
Validate before calling
// optional pre-check before API calls
resp, err := http.Get("https://dev.to/api/articles?per_page=1")
if err != nil {
return fmt.Errorf("dev.to unreachable: %w", err)
}
resp.Body.Close() Try / catch
articles, err := client.FetchArticles(ctx, tag, user, state, perPage)
if err != nil {
var netErr net.Error
if errors.As(err, &netErr) && netErr.Timeout() {
// retry with backoff
}
return nil, err
} Prevention
- Set an explicit Timeout on the http.Client
- Configure HTTP(S)_PROXY for corporate networks
- Use context with a sane deadline and retry transient failures with backoff
When it happens
Trigger: httpClient.Do fails during Refresh or a test — no network connectivity, DNS failure for dev.to, TLS errors, client timeout exceeded, or ctx canceled before completion.
Common situations: Offline laptop or blocked corporate proxy; missing HTTP_PROXY/HTTPS_PROXY config; too-short custom http.Client.Timeout; caller canceling the context mid-request; dev.to outage.
Related errors
- creating request: %w
- unexpected status %d from DEV.to API
- %s
- %s
- yfinance: unexpected status %d for symbol %q
AI-assisted analysis of wtfutil/wtf@bb838c1ccb (2026-09-03).
Data as JSON: /api/errors/14ab030bee87e403.
Report an issue: GitHub.