benbjohnson/litestream · error

failed to delete object %s: %w

Error message

failed to delete object %s: %w

What it means

Wraps objectStore.Delete failure in the NATS replica client's DeleteLTXFiles. Fires when removing an LTX object from the NATS object store fails for reasons other than the object not existing (which is tolerated); replication cleanup cannot complete.

Source

Thrown at nats/replica_client.go:448

		Size:      int64(objectInfo.Size),
		CreatedAt: timestamp,
	}, nil
}

// DeleteLTXFiles deletes one or more LTX files.
func (c *ReplicaClient) DeleteLTXFiles(ctx context.Context, a []*ltx.FileInfo) error {
	if err := c.Init(ctx); err != nil {
		return err
	}

	for _, fileInfo := range a {
		objectPath := c.ltxPath(fileInfo.Level, fileInfo.MinTXID, fileInfo.MaxTXID)

		c.logger.Debug("deleting ltx file", "level", fileInfo.Level, "minTXID", fileInfo.MinTXID, "maxTXID", fileInfo.MaxTXID, "path", objectPath)

		if err := c.objectStore.Delete(ctx, objectPath); err != nil {
			if !isNotFoundError(err) {
				return fmt.Errorf("failed to delete object %s: %w", objectPath, err)
			}
		}
		internal.OperationTotalCounterVec.WithLabelValues(ReplicaClientType, "DELETE").Inc()
	}

	return nil
}

// DeleteAll deletes all files in the object store.
func (c *ReplicaClient) DeleteAll(ctx context.Context) error {
	if err := c.Init(ctx); err != nil {
		return err
	}

	// List all objects in the bucket
	objectList, err := c.objectStore.List(ctx)
	if err != nil {
		// NATS returns "no objects found" when bucket is empty, treat as empty list

View on GitHub (pinned to 4ed7a308f6)

Solutions

  1. Verify delete permissions on the NATS object store
  2. Check NATS connectivity; deletion is retried on the next retention pass
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at nats/replica_client.go:448 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of benbjohnson/litestream@4ed7a308f6 (2026-09-06). Data as JSON: /api/errors/0d673d37fef63bd3. Report an issue: GitHub.