wavetermdev/waveterm · error

reading input: %w

Error message

reading input: %w

What it means

fileWriteRun reads the data to write from stdin via io.LimitReader over WrappedStdin; if the read itself fails the error is wrapped with 'reading input:'. This is an I/O failure on the local stdin pipe, not a remote write failure.

Source

Thrown at cmd/wsh/cmd/wshcmd-file.go:253

		return fmt.Errorf("removing file: %w", err)
	}

	return nil
}

func fileWriteRun(cmd *cobra.Command, args []string) error {
	path, err := fixRelativePaths(args[0])
	if err != nil {
		return err
	}
	fileData := wshrpc.FileData{
		Info: &wshrpc.FileInfo{
			Path: path}}

	limitReader := io.LimitReader(WrappedStdin, MaxFileSize+1)
	data, err := io.ReadAll(limitReader)
	if err != nil {
		return fmt.Errorf("reading input: %w", err)
	}
	if len(data) > MaxFileSize {
		return fmt.Errorf("input exceeds maximum file size of %d bytes", MaxFileSize)
	}
	fileData.Data64 = base64.StdEncoding.EncodeToString(data)
	err = wshclient.FileWriteCommand(RpcClient, fileData, &wshrpc.RpcOpts{Timeout: fileTimeout})
	if err != nil {
		return fmt.Errorf("writing file: %w", err)
	}

	return nil
}

func fileAppendRun(cmd *cobra.Command, args []string) error {
	path, err := fixRelativePaths(args[0])
	if err != nil {
		return err
	}

View on GitHub (pinned to a4447c1563)

Solutions

  1. Re-run the command and confirm the producing side of the pipe completed successfully (check its exit status).
  2. Ensure stdin is actually connected (pipe a file: `wsh file write p < data.bin`).
  3. Bypass custom stdin wrappers in a local build if WrappedStdin is misbehaving.
  4. Verify input integrity (e.g. checksum) and retry the transfer.

Example fix

// before
somecmd | wsh file write out.bin   # somecmd crashed mid-stream
// after
somecmd > tmp.bin && wsh file write out.bin < tmp.bin
Defensive patterns

Strategy: validation

Validate before calling

// verify the producer succeeded before piping
data, err := io.ReadAll(io.LimitReader(WrappedStdin, MaxFileSize+1))
if err != nil {
    return fmt.Errorf("stdin unavailable: %w", err)
}
if len(data) == 0 {
    return fmt.Errorf("no input received on stdin")
}

Try / catch

data, err := io.ReadAll(limitReader)
if err != nil {
    if errors.Is(err, syscall.EPIPE) {
        // producer closed the pipe early — check producer exit status
    }
    return fmt.Errorf("reading input: %w", err)
}

Prevention

When it happens

Trigger: `wsh file write <path>` (or `wsh file write <path> < input`) where the stdin pipe errors: broken pipe from the producing process, stdin closed prematurely, or aWrappedStdin wrapper (e.g. a logging/tapping writer) fails mid-read.

Common situations: Piping from a command that crashed halfway (producer killed), running without supplying stdin so the wrapper errors, disk/terminal I/O issues on the local machine.

Related errors


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