jaegertracing/jaeger · error

failed to delete aliases: %w

Error message

failed to delete aliases: %w

What it means

Returned by IndicesClient.DeleteAlias when the POST to the _aliases endpoint with remove actions fails with a non-ResponseError cause (transport-level failure or unparseable error). The cause is wrapped with %w. Structured ES rejections are returned as a prefixMessage variant naming the aliases.

Source

Thrown at internal/storage/elasticsearch/esclient/index_client.go:207

				return responseError.prefixMessage("failed to create aliases: " + i.aliasesString(aliases))
			}
		}
		return fmt.Errorf("failed to create aliases: %w", err)
	}
	return nil
}

// DeleteAlias an ES specific set of index aliases
func (i *IndicesClient) DeleteAlias(ctx context.Context, aliases []Alias) error {
	err := i.aliasAction(ctx, "remove", aliases)
	if err != nil {
		var responseError ResponseError
		if errors.As(err, &responseError) {
			if responseError.StatusCode != http.StatusOK {
				return responseError.prefixMessage("failed to delete aliases: " + i.aliasesString(aliases))
			}
		}
		return fmt.Errorf("failed to delete aliases: %w", err)
	}
	return nil
}

// AliasExists check whether an alias exists or not
func (i *IndicesClient) AliasExists(ctx context.Context, alias string) (bool, error) {
	_, err := i.request(ctx, elasticRequest{
		endpoint: "_alias/" + alias,
		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 alias exists: %w", err)

View on GitHub (pinned to 806f444784)

Solutions

  1. Confirm ES is up and the configured addresses are correct
  2. Retry DeleteAlias — removing an alias is idempotent
  3. Check proxy/security middleware that might terminate requests without a JSON error body
  4. Unwrap with errors.Is/As to reach the transport-level cause

Example fix

// before
if err := client.DeleteAlias(ctx, oldAliases); err != nil { return err }
// after
if err := client.DeleteAlias(ctx, oldAliases); err != nil {
    var respErr esclient.ResponseError
    if !errors.As(err, &respErr) {
        return retryLater(err) // transport failure: safe to retry
    }
    return err
}
Defensive patterns

Strategy: retry

Validate before calling

// confirm alias currently exists before attempting removal
exists, err := client.AliasExists(ctx, alias.Name)
if err != nil || !exists {
    return nil // nothing to delete
}

Type guard

var respErr esclient.ResponseError
isTransportFailure := !errors.As(err, &respErr)

Try / catch

if err := client.DeleteAlias(ctx, aliases); err != nil {
    var respErr esclient.ResponseError
    if errors.As(err, &respErr) {
        return fmt.Errorf("ES rejected alias removal (status %d): %w", respErr.StatusCode, err)
    }
    return retryWithBackoff(err) // idempotent
}

Prevention

When it happens

Trigger: POST /_aliases with remove actions fails before a structured HTTP error is returned: connection failure, timeout, canceled context, or malformed response body.

Common situations: Removing stale aliases during rollover while ES is being restarted; network partition between Jaeger and ES; security layer (SearchGuard/X-Pack) dropping the request without a JSON error.

Related errors


AI-assisted analysis of jaegertracing/jaeger@806f444784 (2026-09-01). Data as JSON: /api/errors/0483fc08a71737ca. Report an issue: GitHub.