Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/wshrpc/wshremote/wshremote_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,14 @@ func (impl *ServerImpl) RemoteFileStreamCommand(ctx context.Context, data wshrpc

finfo, err := os.Stat(cleanedPath)
if err != nil {
if os.IsNotExist(err) {
writer.Close()
return &wshrpc.FileInfo{
Path: wavebase.ReplaceHomeDir(data.Path),
Dir: computeDirPart(data.Path),
NotFound: true,
}, nil
Comment on lines +568 to +574
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Contract change can silently mask missing files as successful reads.

At Line 568, returning nil error for missing paths changes the stream RPC contract. In pkg/remote/fileshare/wshfs/wshfs.go (Line 70-92), the caller only checks err/IsDir, not FileInfo.NotFound, so this path can continue and treat a non-existent file as a successful empty read.

Please either keep not-found as an error for this RPC, or update stream callers to gate on fileInfo.NotFound before reading.

Suggested caller-side guard (outside this file)
--- a/pkg/remote/fileshare/wshfs/wshfs.go
+++ b/pkg/remote/fileshare/wshfs/wshfs.go
@@
 fileInfo, err := wshclient.RemoteFileStreamCommand(RpcClient, remoteData, &wshrpc.RpcOpts{Route: writerRouteId})
 if err != nil {
 	return nil, fmt.Errorf("starting remote file stream: %w", err)
 }
+if fileInfo != nil && fileInfo.NotFound {
+	return &wshrpc.FileData{Info: fileInfo}, nil
+}
 var rawData []byte
 if fileInfo != nil && !fileInfo.IsDir {
 	rawData, err = io.ReadAll(reader)
 	if err != nil {
 		return nil, fmt.Errorf("reading file stream: %w", err)
 	}
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/wshrpc/wshremote/wshremote_file.go` around lines 568 - 574, The
os.IsNotExist(err) branch in wshremote_file.go currently returns a FileInfo with
NotFound:true and a nil error, which breaks the existing RPC contract because
callers in pkg/remote/fileshare/wshfs/wshfs.go only check err/IsDir and won't
stop reading; change this branch to surface a non-nil error (e.g., return an
os.ErrNotExist or wrap the original err) instead of returning nil so callers see
the file-missing error, ensuring wshrpc.FileInfo.NotFound is not relied on by
existing code; alternatively (if you prefer caller-side change) update the
callers in wshfs.go to explicitly check FileInfo.NotFound before proceeding, but
prefer returning the error from the os.IsNotExist(err) branch to preserve the
original contract.

}
writer.CloseWithError(err)
return nil, fmt.Errorf("cannot stat file %q: %w", data.Path, err)
}
Expand Down
Loading