wavetermdev/waveterm · error

error statting term file: %w

Error message

error statting term file: %w

What it means

After validating arguments, DebugTermCommand calls filestore.WFS.Stat on the block's term file. Any stat error other than fs.ErrNotExist is wrapped as 'error statting term file' and returned, so the caller sees the underlying storage failure.

Source

Thrown at pkg/wshrpc/wshserver/wshserver.go:848

		WorkspaceId: workspaceId,
		Block:       blockData,
		Files:       fileInfoList,
	}, nil
}

func (ws *WshServer) DebugTermCommand(ctx context.Context, data wshrpc.CommandDebugTermData) (*wshrpc.CommandDebugTermRtnData, error) {
	if data.BlockId == "" {
		return nil, fmt.Errorf("blockid is required")
	}
	if data.Size <= 0 {
		return nil, fmt.Errorf("size must be greater than 0")
	}
	waveFile, err := filestore.WFS.Stat(ctx, data.BlockId, wavebase.BlockFile_Term)
	if err == fs.ErrNotExist {
		return &wshrpc.CommandDebugTermRtnData{}, nil
	}
	if err != nil {
		return nil, fmt.Errorf("error statting term file: %w", err)
	}
	readSize := data.Size
	dataLength := waveFile.DataLength()
	if readSize > dataLength {
		readSize = dataLength
	}
	readOffset := waveFile.Size - readSize
	readOffset, readData, err := filestore.WFS.ReadAt(ctx, data.BlockId, wavebase.BlockFile_Term, readOffset, readSize)
	if err != nil {
		return nil, fmt.Errorf("error reading term file: %w", err)
	}
	return &wshrpc.CommandDebugTermRtnData{
		Offset: readOffset,
		Data64: base64.StdEncoding.EncodeToString(readData),
	}, nil
}

func (ws *WshServer) WaveInfoCommand(ctx context.Context) (*wshrpc.WaveInfoData, error) {

View on GitHub (pinned to a4447c1563)

Solutions

  1. Inspect the wrapped %w cause to identify the storage failure
  2. Verify the block ID is valid and the block still exists (note ErrNotExist is handled as empty result, so this error implies a deeper failure)
  3. Check filestore/storage permissions and health for the block domain
Defensive patterns

Strategy: try-catch

Validate before calling

// Optionally verify block exists first
_, err := wcore.GetBlock(ctx, data.BlockId)
if err != nil {
    return fmt.Errorf("block not found: %w", err)
}

Try / catch

resp, err := client.DebugTermCommand(ctx, data)
if err != nil {
    var rootErr error
    errors.As(err, &rootErr) // unwrap 'error statting term file' cause
    return fmt.Errorf("term stat failed: %w", err)
}

Prevention

When it happens

Trigger: WFS.Stat on the block's BlockFile_Term fails with a non-not-exist error: storage backend failure, permission problem, corrupted metadata for the block.

Common situations: Block was deleted between ID acquisition and the call leaving stale state; filestore (ZSVR domain storage) permissions changed; underlying database/storage errors.

Related errors


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