{"record":{"id":"86dc6003cc6678b6","repo":"wtfutil/wtf","slug":"yfinance-unexpected-status-d-for-symbol-q","errorCode":null,"errorMessage":"yfinance: unexpected status %d for symbol %q","messagePattern":"yfinance: unexpected status (.+?) for symbol %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/stocks/yfinance/yquote.go","lineNumber":79,"sourceCode":"func fetchChartMeta(symbol string) (*chartMeta, error) {\n\treqURL := chartAPIBaseURL + url.PathEscape(symbol) + \"?range=1d&interval=1d\"\n\n\treq, err := http.NewRequest(http.MethodGet, reqURL, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// Yahoo's unauthenticated endpoints are more reliable with a\n\t// browser-like User-Agent.\n\treq.Header.Set(\"User-Agent\", \"Mozilla/5.0 (compatible; wtf-yfinance/1.0)\")\n\n\tresp, err := httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"yfinance: unexpected status %d for symbol %q\", resp.StatusCode, symbol)\n\t}\n\n\tvar parsed chartResponse\n\tif err := json.NewDecoder(resp.Body).Decode(&parsed); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif parsed.Chart.Error != nil {\n\t\treturn nil, fmt.Errorf(\"yfinance: API error for symbol %q: %v\", symbol, parsed.Chart.Error)\n\t}\n\n\tif len(parsed.Chart.Result) == 0 {\n\t\treturn nil, fmt.Errorf(\"yfinance: no results for symbol %q\", symbol)\n\t}\n\n\treturn &parsed.Chart.Result[0].Meta, nil\n}\n","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/stocks/yfinance/yquote.go#L61-L97","documentation":"fetchChartMeta in the yfinance module fetches Yahoo Finance chart metadata for a symbol and requires HTTP 200. Any other status code (4xx rate limits/bad symbol routing, 5xx server errors, 429 throttling) aborts with this message carrying the numeric status and the requested symbol.","triggerScenarios":"Any non-200 response from Yahoo's /v8/finance/chart/<symbol> endpoint: 404 for unknown/renamed symbols, 429 when rate-limited by Yahoo, 5xx when Yahoo is degraded, or a proxy/captive portal returning an HTML error page with a non-200 status.","commonSituations":"Yahoo rate-limiting frequent polling from one IP; delisted or renamed tickers configured in the widget; corporate proxies intercepting requests; Yahoo returning 999/403 to non-browser clients.","solutions":["Check the printed status: 429 means slow the widget's refresh interval or add a proxy for Yahoo requests","Verify the symbol is valid by opening the Yahoo Finance chart URL for it in a browser","Retry later for 5xx statuses — these are server-side","Check corporate proxy/firewall interception of the request"],"exampleFix":"// before\nmeta, err := yfinance.FetchMeta(\"BRK\") // 404 unknown symbol\n// after\nmeta, err := yfinance.FetchMeta(\"BRK-B\") // corrected symbol","handlingStrategy":"retry","validationCode":"u := \"https://query1.finance.yahoo.com/v8/finance/chart/\" + url.PathEscape(symbol)\nif symbol == \"\" || strings.ContainsAny(symbol, \" \") { return errors.New(\"invalid symbol\") }\n_ = u","typeGuard":"func isRetryableStatus(code int) bool { return code == 429 || code >= 500 }","tryCatchPattern":"meta, err := fetchChartMeta(symbol)\nif err != nil {\n    var statusErr *statusError\n    if errors.As(err, &statusErr) && statusErr.Code == 429 { backoffAndRetry(symbol) }\n    else { log.Printf(\"yfinance %s: %v\", symbol, err) }\n}","preventionTips":["Keep the widget refresh interval above Yahoo's rate-limit thresholds","Validate symbols against Yahoo before adding them to config","Route Yahoo traffic through a proxy if you see frequent 429s","Handle all three fetchChartMeta error paths separately in callers"],"tags":["http","network","yfinance","go"],"backgroundTag":"http-non-200-response","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"}