wavetermdev/waveterm · error

parsing file path: %w

Error message

parsing file path: %w

What it means

connparse.ParseURI failed on fileData.Info.Path, and streamReadFromFile wraps it with 'parsing file path:'. The wsh CLI expects paths in its URI scheme (plain paths, or wsh://user@host/... remote paths); anything unparseable fails here.

Source

Thrown at cmd/wsh/cmd/wshcmd-file-util.go:107

	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,
		StreamMeta: *streamMeta,
	}
	_, err = wshclient.FileStreamCommand(RpcClient, data, nil)
	if err != nil {
		return fmt.Errorf("starting file stream: %w", err)
	}
	_, err = io.Copy(writer, reader)
	return err

View on GitHub (pinned to a4447c1563)

Solutions

  1. Print/inspect the exact path passed and correct the URI syntax; use plain local paths or valid wsh://user@host/path form.
  2. Quote the argument in the shell to avoid characters being mangled.
  3. If path came from fixRelativePaths, check its output for corruption (double scheme prefix, empty host).

Example fix

// before
wsh file cat ssh://user@host/etc/hosts
// after
wsh file cat wsh://user@host/etc/hosts
Defensive patterns

Strategy: validation

Validate before calling

if _, err := connparse.ParseURI(path); err != nil {
    return fmt.Errorf("invalid wsh path %q: %w", path, err)
}
// path is parseable; proceed to `wsh file cat path`

Try / catch

if err := runWshFileCat(path); err != nil {
    var parseErr *parseErr
    if strings.Contains(err.Error(), "parsing file path") {
        // normalize: strip bad scheme, re-add wsh:// prefix, retry once
    }
    return err
}

Prevention

When it happens

Trigger: `wsh file cat` given a malformed URI, e.g. `wsh://` with no host, an unsupported scheme like `ssh://host/file`, or a path with characters that break the URI parser.

Common situations: Typo in scheme (ssh:// instead of wsh://), stray characters from shell quoting, passing a Windows drive path or a URL copied from a browser into the command.

Related errors


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