wtfutil/wtf · error
%s
Error message
%s
What it means
GetLinks in the subreddit module performs a Reddit HTTP request and rejects any response with status code above 299, returning the raw resp.Status string (e.g. "429 Too Many Requests") as the error. Since it returns the status text, the cause is directly readable.
Source
Thrown at modules/subreddit/api.go:40
}
request.Header.Set("User-Agent", "wtfutil (https://github.com/wtfutil/wtf)")
// See https://www.reddit.com/r/redditdev/comments/t8e8hc/comment/i18yga2/?utm_source=share&utm_medium=web2x&context=3
client := &http.Client{
Transport: &http.Transport{
TLSNextProto: map[string]func(authority string, c *tls.Conn) http.RoundTripper{},
},
}
resp, err := client.Do(request)
if err != nil {
return nil, err
}
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode > 299 {
return nil, fmt.Errorf("%s", resp.Status)
}
var m RedditDocument
err = utils.ParseJSON(&m, resp.Body)
if err != nil {
return nil, err
}
if len(m.Data.Children) == 0 {
return nil, fmt.Errorf("no links")
}
var links []Link
for _, l := range m.Data.Children {
links = append(links, l.Data)
}
return links, nil
}View on GitHub (pinned to bb838c1ccb)
Solutions
- Check the returned status string: 429 means reduce refresh interval
- Verify the subreddit name in config exists and is public
- Set a descriptive custom User-Agent to avoid Reddit's default-UA throttling
- Retry later on 5xx statuses
Example fix
// before "subreddit": "golangxxxx" // 404 // after "subreddit": "golang"
Defensive patterns
Strategy: retry
Validate before calling
if subreddit == "" || strings.ContainsAny(subreddit, "/?&") { return errors.New("invalid subreddit name") } Type guard
func isRateLimited(status string) bool { return strings.HasPrefix(status, "429") } Try / catch
links, err := GetLinks(subreddit)
if err != nil {
var status string
if strings.HasPrefix(err.Error(), "429") { waitAndRetry() } else { log.Printf("reddit: %v", err) }
_ = status
} Prevention
- Set a descriptive custom User-Agent for Reddit requests
- Keep the subreddit refresh interval moderate (Reddit rate-limits aggressively)
- Validate subreddit names exist and are public before adding them
- Expect and handle 403 for quarantined/private subreddits
When it happens
Trigger: Any Reddit API response with status 300+: 403/429 from rate limiting or blocked user-agent, 404 for a nonexistent subreddit, 5xx Reddit outages.
Common situations: Reddit rate-limiting aggressive polling; subreddit renamed/private/banned; missing or generic User-Agent being throttled; Reddit returning 403 to unauthenticated API calls on restricted subreddits.
Related errors
- executing 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/e6715b3fc949d917.
Report an issue: GitHub.