{"record":{"id":"0634de480221868c","repo":"wtfutil/wtf","slug":"yfinance-no-results-for-symbol-q","errorCode":null,"errorMessage":"yfinance: no results for symbol %q","messagePattern":"yfinance: no results for symbol %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/stocks/yfinance/yquote.go","lineNumber":92,"sourceCode":"\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\n// marketState determines whether the quote is trading pre-market, in the\n// regular session, post-market, or closed, based on the trading period\n// windows Yahoo reports for the current day.\nfunc marketState(periods tradingPeriods) string {\n\tnow := time.Now().Unix()\n\n\tswitch {\n\tcase now < periods.Pre.Start:\n\t\treturn \"CLOSED\"\n\tcase now < periods.Regular.Start:\n\t\treturn \"PRE\"\n\tcase now <= periods.Regular.End:\n\t\treturn \"REGULAR\"","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/stocks/yfinance/yquote.go#L74-L110","documentation":"When the chart response is otherwise healthy (HTTP 200, no chart.error) but chart.result is an empty array, fetchChartMeta reports that it got nothing usable for the symbol. This is Yahoo's silent way of saying the symbol matched no data.","triggerScenarios":"HTTP 200 with chart.error == null and len(chart.result) == 0: unknown symbols, symbols with no trading data, or empty-string symbol passed to fetchChartMeta.","commonSituations":"Configuring a delisted ticker; passing an empty symbol when config is missing a required field; querying illiquid/suspended securities that return no results.","solutions":["Confirm the symbol exists and has data on Yahoo Finance","Check widget config for an empty or blank symbol value","Replace delisted/renamed symbols with current ones","Handle the empty-result case in callers if symbols are user-supplied"],"exampleFix":"// before\nsymbol := cfg.Get(\"symbol\") // empty -> \"no results for symbol \\\"\\\"\"\n// after\nsymbol := cfg.Get(\"symbol\")\nif symbol == \"\" { return nil, errors.New(\"symbol not configured\") }","handlingStrategy":"validation","validationCode":"if symbol == \"\" { return errors.New(\"symbol not configured\") }","typeGuard":"func hasResults(cr chartResponse) bool { return len(cr.Chart.Result) > 0 }","tryCatchPattern":"meta, err := fetchChartMeta(symbol)\nif err != nil && strings.Contains(err.Error(), \"no results\") {\n    log.Printf(\"symbol %q has no data; check config\", symbol)\n    return\n}","preventionTips":["Never allow an empty symbol field in widget config","Prune delisted tickers from configuration periodically","Verify each symbol has chart data on Yahoo Finance before adding it","Distinguish empty-result from HTTP errors in caller error handling"],"tags":["yfinance","empty-result","go"],"backgroundTag":"empty-api-result","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"}