wavetermdev/waveterm · error

file info is required

Error message

file info is required

What it means

Read requires the FileData to carry a non-nil Info struct describing the file to read. When data.Info is nil, wshfs cannot determine which path to read and immediately fails with this sentinel error before any RPC is made. It is a guard against a malformed client request.

Source

Thrown at pkg/remote/fileshare/wshfs/wshfs.go:45

	MergeRequiredError          = "directory already exists at %q, set overwrite flag to delete the existing contents or set merge flag to merge the contents"
	OverwriteRequiredError      = "file already exists at %q, set overwrite flag to delete the existing file"
)

// This needs to be set by whoever initializes the client, either main-server or wshcmd-connserver
var RpcClient *wshutil.WshRpc
var RpcClientRouteId string

func parseConnection(ctx context.Context, path string) (*connparse.Connection, error) {
	conn, err := connparse.ParseURIAndReplaceCurrentHost(ctx, path)
	if err != nil {
		return nil, fmt.Errorf("error parsing connection %s: %w", path, err)
	}
	return conn, nil
}

func Read(ctx context.Context, data wshrpc.FileData) (*wshrpc.FileData, error) {
	if data.Info == nil {
		return nil, fmt.Errorf("file info is required")
	}
	log.Printf("Read: %v", data.Info.Path)
	conn, err := parseConnection(ctx, data.Info.Path)
	if err != nil {
		return nil, err
	}
	broker := RpcClient.StreamBroker
	if broker == nil {
		return nil, fmt.Errorf("stream broker not available")
	}
	if RpcClientRouteId == "" {
		return nil, fmt.Errorf("no route id available")
	}
	readerRouteId := RpcClientRouteId
	writerRouteId := wshutil.MakeConnectionRouteId(conn.Host)
	reader, streamMeta := broker.CreateStreamReader(readerRouteId, writerRouteId, 256*1024)
	defer reader.Close()
	go func() {

View on GitHub (pinned to a4447c1563)

Solutions

  1. Always set data.Info with at least Info.Path populated before calling Read
  2. If receiving this over RPC, check the client is serializing the info field
  3. Add a nil check on Info in your wrapper before invoking Read for a clearer error

Example fix

// before
wshfs.Read(ctx, wshrpc.FileData{At: &wshrpc.FileRange{Offset: 0, Size: 1024}})
// after
wshfs.Read(ctx, wshrpc.FileData{Info: &wshrpc.FileInfo{Path: "wsh://host/tmp/f.txt"}, At: &wshrpc.FileRange{Offset: 0, Size: 1024}})
Defensive patterns

Strategy: validation

Validate before calling

if data.Info == nil || data.Info.Path == "" {
    return errors.New("FileData.Info with a Path is required for wshfs.Read")
}

Type guard

func hasFileInfo(d wshrpc.FileData) bool {
    return d.Info != nil && d.Info.Path != ""
}

Try / catch

out, err := wshfs.Read(ctx, data)
if err != nil {
    if strings.Contains(err.Error(), "file info is required") {
        return fmt.Errorf("caller bug: FileData.Info was nil: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Calling wshfs.Read(ctx, wshrpc.FileData{...}) without populating the Info field (e.g. FileData{Data64: ...} or a zero-value FileData), typically via FileReadCommand over RPC.

Common situations: Constructing the RPC payload by hand and forgetting Info; deserializing a request where the info field was dropped; copying example code that only sets Data64.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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