{"record":{"id":"e6f89422facdfa71","repo":"jaegertracing/jaeger","slug":"failed-to-create-index-w","errorCode":null,"errorMessage":"failed to create index: %w","messagePattern":"failed to create index: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/elasticsearch/esclient/index_client.go","lineNumber":177,"sourceCode":"\t\t}\n\t}\n\treturn nil\n}\n\n// CreateIndex an ES index\nfunc (i *IndicesClient) CreateIndex(ctx context.Context, index string) error {\n\t_, err := i.request(ctx, elasticRequest{\n\t\tendpoint: index,\n\t\tmethod:   http.MethodPut,\n\t})\n\tif err != nil {\n\t\tvar responseError ResponseError\n\t\tif errors.As(err, &responseError) {\n\t\t\tif responseError.StatusCode != http.StatusOK {\n\t\t\t\treturn responseError.prefixMessage(\"failed to create index: \" + index)\n\t\t\t}\n\t\t}\n\t\treturn fmt.Errorf(\"failed to create index: %w\", err)\n\t}\n\treturn nil\n}\n\n// CreateAlias an ES specific set of index aliases\nfunc (i *IndicesClient) CreateAlias(ctx context.Context, aliases []Alias) error {\n\terr := i.aliasAction(ctx, \"add\", aliases)\n\tif err != nil {\n\t\tvar responseError ResponseError\n\t\tif errors.As(err, &responseError) {\n\t\t\tif responseError.StatusCode != http.StatusOK {\n\t\t\t\treturn responseError.prefixMessage(\"failed to create aliases: \" + i.aliasesString(aliases))\n\t\t\t}\n\t\t}\n\t\treturn fmt.Errorf(\"failed to create aliases: %w\", err)\n\t}\n\treturn nil\n}","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/elasticsearch/esclient/index_client.go#L159-L195","documentation":"Returned by IndicesClient.CreateIndex when the HTTP PUT that creates an index fails with an error that is not a structured ResponseError (e.g. a transport-level failure). The wrapped err is the real cause. When ES does answer with a structured non-200 response, the ResponseError.prefixMessage variant naming the index is returned instead.","triggerScenarios":"PUT /<index> fails without a parseable ResponseError: network outage, connection reset, TLS error, or request context canceled before a response arrives.","commonSituations":"ES node down or restarting during Jaeger index initialization; wrong port/scheme in ES config; security proxy terminating the connection; short client timeout during cluster startup.","solutions":["Check ES connectivity (curl /_cluster/health) and fix address/credentials in the storage config","Retry CreateIndex — ES returns 400 resource_already_exists_exception if it actually succeeded, so a re-run after a transient failure is safe","Increase the client/request timeout if the cluster was slow to elect a master","Unwrap the error (errors.Is/As on the %w chain) to find the underlying transport cause"],"exampleFix":"// before\nif err := client.CreateIndex(ctx, \"jaeger-span-000001\"); err != nil {\n    return err // transport failure indistinguishable from ES rejection\n}\n// after\nif err := client.CreateIndex(ctx, \"jaeger-span-000001\"); err != nil {\n    var respErr esclient.ResponseError\n    if !errors.As(err, &respErr) {\n        // transport-level failure: safe to retry\n        return retryable(err)\n    }\n    return err\n}","handlingStrategy":"retry","validationCode":"// pre-flight: cluster health\nresp, err := http.Get(esURL + \"/_cluster/health?wait_for_status=yellow&timeout=5s\")\nif err != nil || resp.StatusCode != 200 {\n    return fmt.Errorf(\"ES unavailable, deferring CreateIndex\")\n}","typeGuard":"var respErr esclient.ResponseError\nisTransportFailure := func(err error) bool {\n    var re esclient.ResponseError\n    return !errors.As(err, &re) // no structured ES response => retryable\n}","tryCatchPattern":"if err := client.CreateIndex(ctx, index); err != nil {\n    var respErr esclient.ResponseError\n    if errors.As(err, &respErr) {\n        return fmt.Errorf(\"ES rejected create (status %d): %w\", respErr.StatusCode, err)\n    }\n    return retryWithBackoff(err) // CreateIndex is idempotent (already-exists => 400)\n}","preventionTips":["Run CreateIndex only after cluster health is green/yellow","Treat 'already exists' responses as success to make bootstrap re-runnable","Keep ES address/TLS config validated at startup, not at first use"],"tags":["elasticsearch","network","index-creation"],"backgroundTag":"elasticsearch-request-failed","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}