wavetermdev/waveterm · error
file info is required
Error message
file info is required
What it means
streamReadFromFile in cmd/wsh/cmd/wshcmd-file-util.go requires the FileData to carry a populated Info pointer, because the streaming path needs Info.Path to parse the connection URI and to send to the remote FileStreamCommand. The wsh CLI throws this error when a caller passes FileData with Info == nil.
Source
Thrown at cmd/wsh/cmd/wshcmd-file-util.go:99
appendData := fileData
appendData.Data64 = base64.StdEncoding.EncodeToString(chunk)
err = wshclient.FileAppendCommand(RpcClient, appendData, &wshrpc.RpcOpts{Timeout: int64(fileTimeout)})
if err != nil {
return fmt.Errorf("appending chunk to file: %w", err)
}
}
return nil
}
func streamReadFromFile(ctx context.Context, fileData wshrpc.FileData, writer io.Writer) error {
broker := RpcClient.StreamBroker
if broker == nil {
return fmt.Errorf("stream broker not available")
}
if fileData.Info == nil {
return fmt.Errorf("file info is required")
}
readerRouteId := RpcClientRouteId
if readerRouteId == "" {
return fmt.Errorf("no route id available")
}
conn, err := connparse.ParseURI(fileData.Info.Path)
if err != nil {
return fmt.Errorf("parsing file path: %w", err)
}
writerRouteId := wshutil.MakeConnectionRouteId(conn.Host)
reader, streamMeta := broker.CreateStreamReader(readerRouteId, writerRouteId, 256*1024)
defer reader.Close()
go func() {
<-ctx.Done()
reader.Close()
}()
data := wshrpc.CommandFileStreamData{
Info: fileData.Info,View on GitHub (pinned to a4447c1563)
Solutions
- Ensure FileData.Info is initialized: FileData{Info: &wshrpc.FileInfo{Path: path}} before calling streamReadFromFile.
- If path may be empty, fail early with a clear message before building FileData.
- Check the calling code (fileCatRun) still populates Info after any refactor; add a nil-check guard upstream.
Example fix
// before
fileData := wshrpc.FileData{}
err = streamReadFromFile(ctx, fileData, os.Stdout)
// after
fileData := wshrpc.FileData{Info: &wshrpc.FileInfo{Path: path}}
err = streamReadFromFile(ctx, fileData, os.Stdout) Defensive patterns
Strategy: validation
Validate before calling
if fileData.Info == nil {
return fmt.Errorf("cannot stream file: FileData.Info must be set with a Path")
}
err := streamReadFromFile(ctx, fileData, os.Stdout) Type guard
func hasFileInfo(fd wshrpc.FileData) bool { return fd.Info != nil && fd.Info.Path != "" } Try / catch
if err := streamReadFromFile(ctx, fileData, w); err != nil {
if strings.Contains(err.Error(), "file info is required") {
// caller bug: FileData built without Info — fix construction
}
return err
} Prevention
- Always construct FileData with a non-nil Info: wshrpc.FileData{Info: &wshrpc.FileInfo{Path: path}}.
- Add an upstream nil-check on Info before any stream helper call.
- After refactors, assert FileData construction sites still populate Info.
When it happens
Trigger: Calling streamReadFromFile (via `wsh file cat`) with a wshrpc.FileData whose Info field was never allocated, e.g. FileData{Info: nil} or FileData{} constructed programmatically instead of from CLI args.
Common situations: Custom builds or forks of wsh that construct FileData directly (e.g. from a config value that is empty), or refactors that changed fileCatRun's path handling so the FileInfo literal is skipped when path is empty.
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
- nil wshrpc passed to wshclient
- starting file stream: %w
- no route id available
- parsing file path: %w
- reading file: %w
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/53d2e3c2931e00e0.
Report an issue: GitHub.