jaegertracing/jaeger · error
failed to check if index exists: %w
Error message
failed to check if index exists: %w
What it means
Returned by IndicesClient.IndexExists when the HEAD request against an index fails with anything other than a 404 ResponseError. 404 maps to (false, nil) — index absent. Any other failure becomes this wrapped error, meaning the existence probe itself could not be completed.
Source
Thrown at internal/storage/elasticsearch/esclient/index_client.go:243
return false, fmt.Errorf("failed to check if alias exists: %w", err)
}
return true, nil
}
// IndexExists check whether an index exists or not
func (i *IndicesClient) IndexExists(ctx context.Context, index string) (bool, error) {
_, err := i.request(ctx, elasticRequest{
endpoint: index,
method: http.MethodHead,
})
if err != nil {
var responseError ResponseError
if errors.As(err, &responseError) {
if responseError.StatusCode == http.StatusNotFound {
return false, nil
}
}
return false, fmt.Errorf("failed to check if index exists: %w", err)
}
return true, nil
}
func (*IndicesClient) aliasesString(aliases []Alias) string {
var builder strings.Builder
for _, alias := range aliases {
fmt.Fprintf(&builder, "[index: %s, alias: %s],", alias.Index, alias.Name)
}
concatAliases := builder.String()
return strings.Trim(concatAliases, ",")
}
func (i *IndicesClient) aliasAction(ctx context.Context, action string, aliases []Alias) error {
actions := []map[string]any{}
for _, alias := range aliases {
options := map[string]any{View on GitHub (pinned to 806f444784)
Solutions
- Verify connectivity and credentials (curl -I the index URL); 401/403 point at auth config
- Treat as 'probe failed' — do not assume the index is missing; retry before creating it
- Check cluster health and load-balancer behavior for 5xx responses
- Unwrap the %w chain to identify the transport cause
Example fix
// before
ok, err := client.IndexExists(ctx, "jaeger-span-000001")
if err != nil { return err }
// after
ok, err := client.IndexExists(ctx, "jaeger-span-000001")
if err != nil {
return fmt.Errorf("cannot determine index existence, not bootstrapping: %w", err)
} Defensive patterns
Strategy: try-catch
Validate before calling
// pre-flight auth + connectivity
resp, err := http.Get(esURL + "/_cluster/health")
if err != nil || resp.StatusCode != 200 {
return fmt.Errorf("ES not reachable")
} Type guard
var respErr esclient.ResponseError
isAuthProblem := func(err error) bool {
var re esclient.ResponseError
return errors.As(err, &re) && (re.StatusCode == 401 || re.StatusCode == 403)
} Try / catch
ok, err := client.IndexExists(ctx, index)
if err != nil {
var respErr esclient.ResponseError
if errors.As(err, &respErr) {
return fmt.Errorf("index probe rejected, status=%d", respErr.StatusCode)
}
return retryable(err) // never bootstrap indices on a failed probe
} Prevention
- Only create an index when IndexExists returns (false, nil); an error must abort bootstrap
- Check auth config if you see this at first deployment
- Retry the probe rather than assuming the index is missing
When it happens
Trigger: HEAD /<index> fails without a 404 ResponseError: network outage, timeout, canceled context, or non-404 HTTP errors (401 unauthorized, 503 unavailable) not wrapped as ResponseError.
Common situations: Bad ES credentials during first-time setup; ES down while Jaeger decides whether to bootstrap indices; proxy returning HTML error pages that defeat ResponseError parsing.
Related errors
- failed to delete indices: %w
- failed to resolve backend version: %w
- failed to create index: %w
- failed to create aliases: %w
- failed to delete aliases: %w
AI-assisted analysis of jaegertracing/jaeger@806f444784 (2026-09-01).
Data as JSON: /api/errors/83ac226da97948fd.
Report an issue: GitHub.