wavetermdev/waveterm · error

error getting zone files: %v

Error message

error getting zone files: %v

What it means

DeleteZone first enumerates all file names in a zone via dbGetZoneFileNames, then deletes each file. If the enumeration query fails, the cause is wrapped as 'error getting zone files: %v'. Note that per-file DeleteFile errors during the loop are silently ignored, so this error only covers the listing step.

Source

Thrown at pkg/filestore/blockstore.go:168

		return dbInsertFile(ctx, file)
	})
}

func (s *FileStore) DeleteFile(ctx context.Context, zoneId string, name string) error {
	return withLock(s, zoneId, name, func(entry *CacheEntry) error {
		err := dbDeleteFile(ctx, zoneId, name)
		if err != nil {
			return fmt.Errorf("error deleting file: %v", err)
		}
		entry.clear()
		return nil
	})
}

func (s *FileStore) DeleteZone(ctx context.Context, zoneId string) error {
	fileNames, err := dbGetZoneFileNames(ctx, zoneId)
	if err != nil {
		return fmt.Errorf("error getting zone files: %v", err)
	}
	for _, name := range fileNames {
		s.DeleteFile(ctx, zoneId, name)
	}
	return nil
}

// if file doesn't exsit, returns fs.ErrNotExist
func (s *FileStore) Stat(ctx context.Context, zoneId string, name string) (*WaveFile, error) {
	return withLockRtn(s, zoneId, name, func(entry *CacheEntry) (*WaveFile, error) {
		file, err := entry.loadFileForRead(ctx)
		if err != nil {
			if err == fs.ErrNotExist {
				return nil, err
			}
			return nil, fmt.Errorf("error getting file: %v", err)
		}
		return file.DeepCopy(), nil

View on GitHub (pinned to a4447c1563)

Solutions

  1. Inspect the wrapped cause to identify the DB failure; retry transient errors with a valid context.
  2. Ensure the store/DB is open and reachable before calling DeleteZone.
  3. Check for context cancellation from the caller and use a fresh context for teardown-time deletes.
  4. Verify the zone metadata tables are intact if the error is persistent.

Example fix

// before
for _, name := range fileNames {
	s.DeleteFile(ctx, zoneId, name) // errors swallowed
}
// after
for _, name := range fileNames {
	if err := s.DeleteFile(ctx, zoneId, name); err != nil {
		return fmt.Errorf("error deleting file %q in zone: %w", name, err)
	}
}
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-check context and store availability before teardown
if ctx.Err() != nil { return ctx.Err() }

Try / catch

if err := store.DeleteZone(ctx, zoneId); err != nil {
	if strings.Contains(err.Error(), "error getting zone files:") {
		// retry transient listing failure
		err = store.DeleteZone(ctx, zoneId)
	}
	if err != nil {
		return fmt.Errorf("delete zone %s: %w", zoneId, err)
	}
}

Prevention

When it happens

Trigger: dbGetZoneFileNames returns an error: backing DB unavailable/closed, context cancelled or deadline exceeded, or a storage-layer failure while querying file names for the zone.

Common situations: Tearing down zones after the store has been closed; cancelled request contexts during shutdown; DB lock contention with concurrent writers; corrupted zone metadata preventing the name listing.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/dc9cc65e8ec39e78. Report an issue: GitHub.