{"record":{"id":"fb551fd8fe552e1c","repo":"jaegertracing/jaeger","slug":"failed-to-get-latest-index-w","errorCode":null,"errorMessage":"failed to get latest index: %w","messagePattern":"failed to get latest index: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/v1/elasticsearch/samplingstore/storage.go","lineNumber":126,"sourceCode":"func (s *SamplingStore) InsertProbabilitiesAndQPS(hostname string,\n\tprobabilities model.ServiceOperationProbabilities,\n\tqps model.ServiceOperationQPS,\n) error {\n\tts := s.now()\n\twriteIndexName := s.rotation.WriteTarget(ts)\n\tval := dbmodel.ProbabilitiesAndQPS{\n\t\tHostname:      hostname,\n\t\tProbabilities: probabilities,\n\t\tQPS:           qps,\n\t}\n\treturn s.writeProbabilitiesAndQPS(writeIndexName, ts, val)\n}\n\nfunc (s *SamplingStore) GetLatestProbabilities() (model.ServiceOperationProbabilities, error) {\n\tctx := context.Background()\n\tindex, err := s.getLatestIndex(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get latest index: %w\", err)\n\t}\n\tsearchResult, err := s.searcher.Search(ctx, []string{index}, esclient.SearchRequest{\n\t\tSize: s.maxDocCount,\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to search for Latest Probabilities: %w\", err)\n\t}\n\tlengthOfSearchResult := len(searchResult.Hits.Hits)\n\tif lengthOfSearchResult == 0 {\n\t\treturn nil, nil\n\t}\n\n\tvar latestProbabilities dbmodel.TimeProbabilitiesAndQPS\n\tlatestTime := time.Time{}\n\tfor _, hit := range searchResult.Hits.Hits {\n\t\tvar data dbmodel.TimeProbabilitiesAndQPS\n\t\tif err = json.Unmarshal(hit.Source, &data); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unmarshalling documents failed: %w\", err)","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v1/elasticsearch/samplingstore/storage.go#L108-L144","documentation":"GetLatestProbabilities in the Elasticsearch sampling store wraps any failure from getLatestIndex with this message. getLatestIndex iterates the rotation-eligible index candidates within the lookback window and returns an error if none exist or the existence check itself fails. The wrapper preserves the underlying cause via %w so callers can inspect it with errors.Is/As.","triggerScenarios":"Calling GetLatestProbabilities when no sampling index for the current rotation window exists, or when IndexExists returns a transport/cluster error (e.g. ES down, bad URL, auth failure) for every candidate index.","commonSituations":"Elasticsearch unreachable or misconfigured (wrong addresses/credentials); the sampling index was never created because the collector has not written any sampling data yet; lookback/rotation settings point at a date range with no indices; index name prefix changed between versions.","solutions":["Verify Elasticsearch connectivity and credentials (curl the cluster health endpoint using the configured addresses).","Check that sampling data has been written at least once so an index exists; inspect index names with GET /_cat/indices.","Align lookback/rotation/prefix configuration so candidates cover the indices actually present.","Inspect the wrapped cause with errors.Unwrap to distinguish 'no index found' from an ES client error."],"exampleFix":"// before\nidx, err := store.GetLatestProbabilities()\n// after\nif err != nil {\n  if strings.Contains(err.Error(), \"failed to find latest index\") {\n    // fall back to default probabilities; no sampling index yet\n  } else {\n    log.Fatal(err) // real ES connectivity problem\n  }\n}","handlingStrategy":"fallback","validationCode":"if err != nil {\n  if strings.Contains(err.Error(), \"failed to find latest index\") {\n    probs = defaultProbabilities // no index yet\n  }\n}","typeGuard":null,"tryCatchPattern":"probs, err := store.GetLatestProbabilities()\nif err != nil {\n  log.Printf(\"sampling probabilities unavailable: %v\", err)\n  probs = defaultProbabilities\n}","preventionTips":["Ensure the collector writes sampling data before readers query it.","Monitor ES cluster health from the storage client.","Keep rotation lookback/prefix config consistent across writers and readers."],"tags":["elasticsearch","storage","sampling"],"backgroundTag":"index-not-found","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}