Conversation
WalkthroughThe Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pkg/wshrpc/wshremote/wshremote_file.go`:
- Around line 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.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 136bbaa0-972e-402c-87cf-83c0d80b2714
📒 Files selected for processing (1)
pkg/wshrpc/wshremote/wshremote_file.go
| if os.IsNotExist(err) { | ||
| writer.Close() | ||
| return &wshrpc.FileInfo{ | ||
| Path: wavebase.ReplaceHomeDir(data.Path), | ||
| Dir: computeDirPart(data.Path), | ||
| NotFound: true, | ||
| }, nil |
There was a problem hiding this comment.
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.
No description provided.